diff options
Diffstat (limited to 'azalea-protocol/src')
| -rwxr-xr-x | azalea-protocol/src/read.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs index 01744169..84c307d7 100755 --- a/azalea-protocol/src/read.rs +++ b/azalea-protocol/src/read.rs @@ -117,6 +117,13 @@ fn parse_frame(buffer: &mut Cursor<Vec<u8>>) -> Result<Box<[u8]>, FrameSplitterE // reset the inner vec once we've reached the end of the buffer so we don't keep // leaking memory buffer.get_mut().clear(); + + // we just cap the capacity to 64KB instead of resetting it to save some + // allocations. + // and the reason we bother capping it at all is to avoid wasting memory if we + // get a big packet once and then never again. + buffer.get_mut().shrink_to(1024 * 64); + buffer.set_position(0); } |
