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:
parent
6d88f966e1
commit
6b57654b03
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue