From dd557c8f293dbef3e2e881bcb1a85a7697a1ebbb Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 23 Feb 2025 08:47:17 +0000 Subject: fix memory leak in simulation tests (lol) also, change some vecs into boxed slices, and add RelativeEntityUpdate::new --- azalea-world/src/chunk_storage.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'azalea-world/src/chunk_storage.rs') diff --git a/azalea-world/src/chunk_storage.rs b/azalea-world/src/chunk_storage.rs index 455d87e7..9592abbf 100755 --- a/azalea-world/src/chunk_storage.rs +++ b/azalea-world/src/chunk_storage.rs @@ -31,7 +31,7 @@ pub struct PartialChunkStorage { chunk_radius: u32, view_range: u32, // chunks is a list of size chunk_radius * chunk_radius - chunks: Vec>>>, + chunks: Box<[Option>>]>, } /// A storage for chunks where they're only stored weakly, so if they're not @@ -50,7 +50,7 @@ pub struct ChunkStorage { /// coordinate. #[derive(Debug)] pub struct Chunk { - pub sections: Vec
, + pub sections: Box<[Section]>, /// Heightmaps are used for identifying the surface blocks in a chunk. /// Usually for clients only `WorldSurface` and `MotionBlocking` are /// present. @@ -84,7 +84,7 @@ impl Default for Section { impl Default for Chunk { fn default() -> Self { Chunk { - sections: vec![Section::default(); (384 / 16) as usize], + sections: vec![Section::default(); (384 / 16) as usize].into(), heightmaps: HashMap::new(), } } @@ -97,7 +97,7 @@ impl PartialChunkStorage { view_center: ChunkPos::new(0, 0), chunk_radius, view_range, - chunks: vec![None; (view_range * view_range) as usize], + chunks: vec![None; (view_range * view_range) as usize].into(), } } @@ -341,6 +341,7 @@ impl Chunk { let section = Section::azalea_read(buf)?; sections.push(section); } + let sections = sections.into_boxed_slice(); let mut heightmaps = HashMap::new(); for (name, heightmap) in heightmaps_nbt.iter() { -- cgit v1.2.3