diff options
| author | mat <github@matdoes.dev> | 2022-08-24 21:02:11 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-08-24 21:02:11 -0500 |
| commit | e33d57e767a8cc87d9616298c10b374fa0c72efe (patch) | |
| tree | cf36006b00e70a0a17cf45c54cc3948d9c06eea1 /azalea-nbt/src/decode.rs | |
| parent | 2a2e82efeb4e090abf9144b39be834972c7a0a4d (diff) | |
| download | azalea-drasl-e33d57e767a8cc87d9616298c10b374fa0c72efe.tar.xz | |
optimize nbt bytearray
Diffstat (limited to 'azalea-nbt/src/decode.rs')
| -rwxr-xr-x | azalea-nbt/src/decode.rs | 6 |
1 files changed, 2 insertions, 4 deletions
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::<BE>()?; - 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 |
