Avoid large allocations of temporary buffers in BuferUtil (#5045)

* Avoid large allocations of tmp buffers in buferutil

Signed-off-by: Sergey Tselovalnikov <sergeicelov@gmail.com>

* review feedback

Signed-off-by: Sergey Tselovalnikov <sergeicelov@gmail.com>
This commit is contained in:
Sergey Tselovalnikov 2020-07-15 18:07:27 +10:00 committed by GitHub
parent 6d88f966e1
commit 6b57654b03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -553,7 +553,7 @@ public class BufferUtil
}
else
{
byte[] bytes = new byte[TEMP_BUFFER_SIZE];
byte[] bytes = new byte[Math.min(buffer.remaining(), TEMP_BUFFER_SIZE)];
while (buffer.hasRemaining())
{
int byteCountToWrite = Math.min(buffer.remaining(), TEMP_BUFFER_SIZE);