diff options
| author | mat <git@matdoes.dev> | 2025-02-21 22:50:19 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-02-21 22:50:39 +0000 |
| commit | 27945c8870c832970dfe15b9bf9f567c0ad96ea4 (patch) | |
| tree | 08c6598d52ac379505ec556ffb7d40aec5dcb3d8 /azalea-protocol/src | |
| parent | f5f15362f2cb48088eb8ccf80988f994fecd81c9 (diff) | |
| download | azalea-drasl-27945c8870c832970dfe15b9bf9f567c0ad96ea4.tar.xz | |
despawn entities when switching worlds and some testbot fixes
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); } |
