fix another size-recalculation mistake in 'PersistentVector.splitRight' function. (When we are splitting in the middle of a BRANCH, we want to subtract the old child size from the remainder, and then add the new child size to the remainder, because this calculation will account for the splitting of preceding elements.)

This commit is contained in:
2026-01-16 22:40:38 +00:00
parent e52d4856ee
commit 98ec1fbee6

View File

@@ -450,13 +450,16 @@ struct
else else
let let
val newChildSize = getFinishIdx child val newChildSize = getFinishIdx child
val difference = oldChildSize - newChildSize
val sizes = Vector.tabulate (VectorSlice.length sizesSlice + 1, val sizes = Vector.tabulate (VectorSlice.length sizesSlice + 1,
fn i => fn i =>
if i = 0 then if i = 0 then
newChildSize newChildSize
else else
VectorSlice.sub (sizesSlice, i - 1) - difference let
val el = VectorSlice.sub (sizesSlice, i - 1)
in
el - oldChildSize + newChildSize
end
) )
val child = VectorSlice.full #[child] val child = VectorSlice.full #[child]