In:

@@ -196,14 +194,32 @@
         return len;
     }

+    public synchronized byte[] readAllBytes() {
+        byte[] result = Arrays.copyOfRange(buf, pos, count);
+        pos = count;
+        return result;
+    }
+
+    public synchronized int readNBytes(byte[] b, int off, int len) {
+        int n = read(b, off, len);
+        return n == -1 ? 0 : n;
+    }

This probably doesn't need to be synchronized, though I imagine the
difference would be minimal.

+    public synchronized long transferTo(OutputStream out) throws IOException {
+        int len = count - pos
+        out.write(but, pos, len);

s/but/buf/ I guess?

+        pos = count;
+        return len;
+    }
+

On Wed, Mar 14, 2018 at 10:31 AM, Brian Burkhalter
<brian.burkhal...@oracle.com> wrote:
> Reprising this thread from three months ago [1].
>
> A patch including the changes suggested below is at
>
> http://cr.openjdk.java.net/~bpb/8180451/webrev.01/
>
> with the differences between this and the prior version at
>
> http://cr.openjdk.java.net/~bpb/8180451/webrev.00-01/
>
> Thanks,
>
> Brian
>
> [1] 
> http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-December/050550.html
>
> On Dec 12, 2017, at 11:42 AM, Paul Sandoz <paul.san...@oracle.com> wrote:
>
>> 208     public synchronized long transferTo(OutputStream out) throws 
>> IOException {
>> 209         int pos0 = pos;
>> 210         out.write(buf, pos, count - pos);
>> 211         pos = count;
>> 212         return count - pos0;
>> 213     }
>>
>>  int len = count - pos
>>  out.write(but, pos, len);
>>  pos = count;
>>  return len;
>
> On Dec 12, 2017, at 12:23 PM, Brent Christian <brent.christ...@oracle.com> 
> wrote:
>
>> The changes look fine to me.
>> I would have found the test case a little easier to follow if "off"/"len" 
>> weren't named so similarly to "offset"/"length", but it's not a big deal.
>
>



-- 
- DML

Reply via email to