diff options
Diffstat (limited to 'azalea-world/src')
| -rwxr-xr-x | azalea-world/src/bit_storage.rs | 6 | ||||
| -rwxr-xr-x | azalea-world/src/chunk_storage.rs | 9 | ||||
| -rwxr-xr-x | azalea-world/src/palette.rs | 2 |
3 files changed, 9 insertions, 8 deletions
diff --git a/azalea-world/src/bit_storage.rs b/azalea-world/src/bit_storage.rs index 2af7427d..1b0c1a56 100755 --- a/azalea-world/src/bit_storage.rs +++ b/azalea-world/src/bit_storage.rs @@ -72,7 +72,7 @@ const MAGIC: [(i32, i32, i32); 64] = [ /// A compact list of integers with the given number of bits per entry. #[derive(Clone, Debug, Default)] pub struct BitStorage { - pub data: Vec<u64>, + pub data: Box<[u64]>, bits: usize, mask: u64, size: usize, @@ -106,7 +106,7 @@ impl BitStorage { // 0 bit storage if data.is_empty() { return Ok(BitStorage { - data: Vec::new(), + data: Box::new([]), bits, size, ..Default::default() @@ -136,7 +136,7 @@ impl BitStorage { }; Ok(BitStorage { - data: using_data, + data: using_data.into(), bits, mask, size, 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() { diff --git a/azalea-world/src/palette.rs b/azalea-world/src/palette.rs index 9b1a8642..dd5f7daa 100755 --- a/azalea-world/src/palette.rs +++ b/azalea-world/src/palette.rs @@ -49,7 +49,7 @@ impl PalettedContainer { let palette_type = PaletteKind::from_bits_and_type(server_bits_per_entry, container_type); let palette = palette_type.read(buf)?; let size = container_type.size(); - let data = Vec::<u64>::azalea_read(buf)?; + let data = Box::<[u64]>::azalea_read(buf)?; // we can only trust the bits per entry that we're sent if there's enough data // that it'd be global. if it's not global, then we have to calculate it |
