amend recalculation of size metadata in 'PersistentVector.splitRIght: we always want to decrement by prevSize in this function. (We will have another function call to decrement so that left split and right split represent the same absolute indices when they are joined, before they are split.)

This commit is contained in:
2026-01-16 22:31:43 +00:00
parent ddcb0ea56d
commit e52d4856ee

View File

@@ -443,7 +443,7 @@ struct
else
let
val nodes = VectorSlice.vector nodesSlice
val sizes = VectorSlice.map (fn el => el - prevSize) sizesSlice
val sizes = VectorSlice.map (fn el => el - oldChildSize) sizesSlice
in
BRANCH (nodes, sizes)
end
@@ -487,11 +487,16 @@ struct
empty
else
let
val prevSize =
if idx > 0 then
Vector.sub (sizes, idx - 1)
else
0
val len = Vector.length items - idx
val itemsSlice = VectorSlice.slice (items, idx, SOME len)
val items = VectorSlice.map
(fn {start, finish} =>
{start = start - splitIdx, finish = finish - splitIdx}
{start = start - prevSize, finish = finish - prevSize}
)
itemsSlice
val sizes = Vector.map #finish items