From e33d57e767a8cc87d9616298c10b374fa0c72efe Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 24 Aug 2022 21:02:11 -0500 Subject: optimize nbt bytearray --- azalea-nbt/src/decode.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'azalea-nbt/src/decode.rs') diff --git a/azalea-nbt/src/decode.rs b/azalea-nbt/src/decode.rs index 5164bb0f..d4760807 100755 --- a/azalea-nbt/src/decode.rs +++ b/azalea-nbt/src/decode.rs @@ -40,10 +40,8 @@ impl Tag { // integer (thus 4 bytes) 7 => { let length = stream.read_i32::()?; - let mut bytes = Vec::with_capacity(length as usize); - for _ in 0..length { - bytes.push(stream.read_i8()?); - } + let mut bytes = vec![0; length as usize]; + stream.read_exact(&mut bytes)?; Tag::ByteArray(bytes) } // A length-prefixed modified UTF-8 string. The prefix is an -- cgit v1.2.3