RFR [8014657] CheckedInputStream.skip allocates temporary buffer on every call (original) (raw)
Xueming Shen xueming.shen at oracle.com
Wed May 15 16:34:10 UTC 2013
- Previous message: RFR [8014657] CheckedInputStream.skip allocates temporary buffer on every call
- Next message: RFR [8014657] CheckedInputStream.skip allocates temporary buffer on every call
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
public long skip(long n) throws IOException {
byte[] buf = new byte[512];
if (tmpbuf == null) {
tmpbuf = new byte[512];
} long total = 0; while (total < n) { long len = n - total;
len = read(buf, 0, len < buf.length ? (int)len : buf.length);
len = read(buf, 0, len < tmpbuf.length ? (int)len : tmpbuf.length); if (len == -1) { return total; } total += len; }
Shouldn't the first param "buf" to be "tmpbuf" as well at ln#104, otherwise I guess it will not pass the compiler?
-Sherman
On 05/15/2013 08:40 AM, Ivan Gerasimov wrote:
Hello!
Please have a chance to review a simple change proposal. CheckedInputStream.skip() allocates temporary buffer on every call. It's suggested to have a temporary buffer that is initialized on the first use and can be reused during subsequent calls to the skip() function. Many other input streams already use the same approach. http://cr.openjdk.java.net/~dmeetry/8014657/webrev.0/ <http://cr.openjdk.java.net/%7Edmeetry/8014657/webrev.0/> Sincerely, Ivan
- Previous message: RFR [8014657] CheckedInputStream.skip allocates temporary buffer on every call
- Next message: RFR [8014657] CheckedInputStream.skip allocates temporary buffer on every call
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]