From ed4c4e0fb846b0c78f3d27025c0dbad5adea6686 Mon Sep 17 00:00:00 2001 From: nobuildersnotools Date: Sat, 29 Aug 2026 21:39:46 -0400 Subject: [PATCH] perf: read nbt byte arrays in bulk (#2784) --- crates/pumpkin-nbt/src/tag.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/crates/pumpkin-nbt/src/tag.rs b/crates/pumpkin-nbt/src/tag.rs index d9de84265..34c5b1b34 100644 --- a/crates/pumpkin-nbt/src/tag.rs +++ b/crates/pumpkin-nbt/src/tag.rs @@ -350,12 +350,7 @@ impl NbtTag { if len > crate::MAX_ARRAY_LENGTH { return Err(Error::LargeLength(len)); } - let mut byte_array = Vec::with_capacity(len.min(4096)); - for _ in 0..len { - let byte = reader.get_i8()?; - byte_array.push(byte); - } - Ok(Self::ByteArray(byte_array.into())) + Ok(Self::ByteArray(reader.get_byte_array(len)?.into())) } STRING_ID => Ok(Self::String(reader.get_string()?.into_owned().into())), LIST_ID => {