1
0
Fork 0
mirror of https://github.com/azalea-rs/simdnbt.git synced 2025-08-02 07:26:04 +00:00

revert using push_unchecked for first tape push

This commit is contained in:
mat 2025-01-18 20:38:54 +00:00
parent 646d5a33ec
commit 1a4fa2d7ee

View file

@ -48,22 +48,17 @@ pub fn read<'a>(data: &mut Cursor<&'a [u8]>) -> Result<Nbt<'a>, Error> {
let name = read_string(&mut data)?;
let mut tapes = Tapes::new();
let mut stack = ParsingStack::new();
tapes.main.push(TapeElement::new_with_approx_len_and_offset(
TapeTagKind::Compound,
// these get overwritten later
0,
0,
));
let mut stack = ParsingStack::new();
stack.push(ParsingStackElement::Compound {
index_of_compound_element: 0,
})?;
unsafe {
// SAFETY: we just created the MainTape so there's definitely space for an item
tapes
.main
.push_unchecked(TapeElement::new_with_approx_len_and_offset(
TapeTagKind::Compound,
// these get overwritten later
0,
0,
))
};
read_with_stack(&mut data, &mut tapes, &mut stack)?;
@ -96,17 +91,13 @@ pub fn read_compound<'a>(data: &mut Cursor<&'a [u8]>) -> Result<BaseNbtCompound<
stack.push(ParsingStackElement::Compound {
index_of_compound_element: 0,
})?;
unsafe {
// SAFETY: we just created the MainTape so there's definitely space for an item
tapes
.main
.push_unchecked(TapeElement::new_with_approx_len_and_offset(
TapeTagKind::Compound,
// these get overwritten later
0,
0,
))
};
tapes.main.push(TapeElement::new_with_approx_len_and_offset(
TapeTagKind::Compound,
// these get overwritten later
0,
0,
));
read_with_stack(&mut data, &mut tapes, &mut stack)?;