Skip to content

Commit 42f7413

Browse files
committed
reduce allocations in transferTo()
1 parent e030806 commit 42f7413

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main/java/robaho/net/httpserver/NoSyncBufferedInputStream.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,15 @@ public long transferTo(OutputStream out) throws IOException {
262262
out.write(buf,pos,count-pos);
263263
pos = count;
264264
}
265-
return super.transferTo(out);
265+
long total = avail;
266+
while (true) {
267+
fill();
268+
if (count <= 0) {
269+
break;
270+
}
271+
out.write(buf, 0, count);
272+
total += count;
273+
}
274+
return total;
266275
}
267276
}

0 commit comments

Comments
 (0)