perf: read nbt byte arrays in bulk (#2784)

This commit is contained in:
nobuildersnotools
2026-08-29 21:39:46 -04:00
committed by GitHub
parent 74b5532636
commit ed4c4e0fb8

View File

@@ -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 => {