mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-30 20:14:23 +00:00
perf: write nbt byte arrays in bulk (#2785)
This commit is contained in:
committed by
GitHub
parent
ed4c4e0fb8
commit
538cea363b
@@ -141,9 +141,11 @@ impl NbtTag {
|
||||
}
|
||||
|
||||
w.write_i32(len as i32)?;
|
||||
for int in byte_array {
|
||||
w.write_i8(int)?;
|
||||
}
|
||||
// SAFETY: `i8` and `u8` have identical layouts, and the slice is only read.
|
||||
let bytes = unsafe {
|
||||
std::slice::from_raw_parts(byte_array.as_ptr().cast::<u8>(), byte_array.len())
|
||||
};
|
||||
w.write_slice(bytes)?;
|
||||
}
|
||||
Self::String(string) => {
|
||||
w.write_string(&string)?;
|
||||
|
||||
Reference in New Issue
Block a user