From 3667975190c51006c1d5735277a9e2bdc55146a2 Mon Sep 17 00:00:00 2001 From: nobuildersnotools Date: Sat, 29 Aug 2026 21:57:50 -0400 Subject: [PATCH] perf: preallocate direct palette data (#2786) --- crates/pumpkin-world/src/chunk/palette.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/pumpkin-world/src/chunk/palette.rs b/crates/pumpkin-world/src/chunk/palette.rs index 2a720570d..39ed39a7e 100644 --- a/crates/pumpkin-world/src/chunk/palette.rs +++ b/crates/pumpkin-world/src/chunk/palette.rs @@ -526,7 +526,8 @@ impl BiomePalette { if raw_bits_per_entry > BIOME_NETWORK_MAX_MAP_BITS { let bits_per_entry = BIOME_NETWORK_MAX_BITS; let values_per_i64 = 64 / bits_per_entry; - let mut packed_data = Vec::new(); + let mut packed_data = + Vec::with_capacity(Self::VOLUME.div_ceil(values_per_i64 as usize)); let mut current_idx = 0; while current_idx < Self::VOLUME { let mut acc = 0u64; @@ -735,7 +736,8 @@ impl BlockPalette { if raw_bits_per_entry > BLOCK_NETWORK_MAX_MAP_BITS { let bits_per_entry = BLOCK_NETWORK_MAX_BITS; let values_per_i64 = 64 / bits_per_entry; - let mut packed_data = Vec::new(); + let mut packed_data = + Vec::with_capacity(Self::VOLUME.div_ceil(values_per_i64 as usize)); let mut current_idx = 0; while current_idx < Self::VOLUME { let mut acc = 0u64;