diff options
| author | mat <git@matdoes.dev> | 2025-02-23 08:47:17 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-02-23 08:47:17 +0000 |
| commit | dd557c8f293dbef3e2e881bcb1a85a7697a1ebbb (patch) | |
| tree | 9878084875ac8ca7259db26b2c16776f212802a3 /azalea-world/src/chunk_storage.rs | |
| parent | e21e1b97bf9337e9f4747cd1b545b1b3a03e2ce7 (diff) | |
| download | azalea-drasl-dd557c8f293dbef3e2e881bcb1a85a7697a1ebbb.tar.xz | |
fix memory leak in simulation tests (lol)
also, change some vecs into boxed slices, and add RelativeEntityUpdate::new
Diffstat (limited to 'azalea-world/src/chunk_storage.rs')
| -rwxr-xr-x | azalea-world/src/chunk_storage.rs | 9 |
1 files changed, 5 insertions, 4 deletions
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<Option<Arc<RwLock<Chunk>>>>, + chunks: Box<[Option<Arc<RwLock<Chunk>>>]>, } /// 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<Section>, + 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() { |
