mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8206290: Better FileChannel transfer performance
Reviewed-by: alanb, rhalade, mschoene
This commit is contained in:
parent
24218b904d
commit
68f33ebd5a
1 changed files with 2 additions and 8 deletions
|
@ -624,11 +624,10 @@ public class FileChannelImpl
|
||||||
{
|
{
|
||||||
// Untrusted target: Use a newly-erased buffer
|
// Untrusted target: Use a newly-erased buffer
|
||||||
int c = Math.min(icount, TRANSFER_SIZE);
|
int c = Math.min(icount, TRANSFER_SIZE);
|
||||||
ByteBuffer bb = Util.getTemporaryDirectBuffer(c);
|
ByteBuffer bb = ByteBuffer.allocate(c);
|
||||||
long tw = 0; // Total bytes written
|
long tw = 0; // Total bytes written
|
||||||
long pos = position;
|
long pos = position;
|
||||||
try {
|
try {
|
||||||
Util.erase(bb);
|
|
||||||
while (tw < icount) {
|
while (tw < icount) {
|
||||||
bb.limit(Math.min((int)(icount - tw), TRANSFER_SIZE));
|
bb.limit(Math.min((int)(icount - tw), TRANSFER_SIZE));
|
||||||
int nr = read(bb, pos);
|
int nr = read(bb, pos);
|
||||||
|
@ -649,8 +648,6 @@ public class FileChannelImpl
|
||||||
if (tw > 0)
|
if (tw > 0)
|
||||||
return tw;
|
return tw;
|
||||||
throw x;
|
throw x;
|
||||||
} finally {
|
|
||||||
Util.releaseTemporaryDirectBuffer(bb);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,11 +731,10 @@ public class FileChannelImpl
|
||||||
{
|
{
|
||||||
// Untrusted target: Use a newly-erased buffer
|
// Untrusted target: Use a newly-erased buffer
|
||||||
int c = (int)Math.min(count, TRANSFER_SIZE);
|
int c = (int)Math.min(count, TRANSFER_SIZE);
|
||||||
ByteBuffer bb = Util.getTemporaryDirectBuffer(c);
|
ByteBuffer bb = ByteBuffer.allocate(c);
|
||||||
long tw = 0; // Total bytes written
|
long tw = 0; // Total bytes written
|
||||||
long pos = position;
|
long pos = position;
|
||||||
try {
|
try {
|
||||||
Util.erase(bb);
|
|
||||||
while (tw < count) {
|
while (tw < count) {
|
||||||
bb.limit((int)Math.min((count - tw), (long)TRANSFER_SIZE));
|
bb.limit((int)Math.min((count - tw), (long)TRANSFER_SIZE));
|
||||||
// ## Bug: Will block reading src if this channel
|
// ## Bug: Will block reading src if this channel
|
||||||
|
@ -759,8 +755,6 @@ public class FileChannelImpl
|
||||||
if (tw > 0)
|
if (tw > 0)
|
||||||
return tw;
|
return tw;
|
||||||
throw x;
|
throw x;
|
||||||
} finally {
|
|
||||||
Util.releaseTemporaryDirectBuffer(bb);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue