Skip to content

Commit 97431ff

Browse files
committed
part: Mark newly created nodes as mutated
We can mark the node4 created when splitting and the nodes created when demoted as mutated so we don't need to clone them on further modifications. Signed-off-by: Jussi Maki <[email protected]>
1 parent fbe474a commit 97431ff

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

part/txn.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ func (txn *Txn[T]) modify(root *header[T], key []byte, mod func(T) T) (oldValue
360360
newNode.setSize(2)
361361
}
362362
*thisp = newNode.self()
363+
nodeMutatedSet(txn.mutated, newNode.self())
363364

364365
return
365366
}
@@ -511,6 +512,7 @@ func (txn *Txn[T]) removeChild(parent *header[T], index int) *header[T] {
511512
childClone := child.clone(false)
512513
childClone.watch = child.watch
513514
childClone.setPrefix(slices.Concat(parent.prefix(), childClone.prefix()))
515+
nodeMutatedSet(txn.mutated, childClone)
514516
return childClone
515517

516518
case parent.kind() == nodeKind256 && size <= 49:
@@ -526,6 +528,7 @@ func (txn *Txn[T]) removeChild(parent *header[T], index int) *header[T] {
526528
children = append(children, n)
527529
}
528530
}
531+
nodeMutatedSet(txn.mutated, demoted)
529532
return demoted
530533
case parent.kind() == nodeKind48 && size <= 17:
531534
demoted := (&node16[T]{header: *parent}).self()
@@ -541,6 +544,7 @@ func (txn *Txn[T]) removeChild(parent *header[T], index int) *header[T] {
541544
idx++
542545
}
543546
}
547+
nodeMutatedSet(txn.mutated, demoted)
544548
return demoted
545549
case parent.kind() == nodeKind16 && size <= 5:
546550
demoted := (&node4[T]{header: *parent}).self()
@@ -557,6 +561,7 @@ func (txn *Txn[T]) removeChild(parent *header[T], index int) *header[T] {
557561
idx++
558562
}
559563
}
564+
nodeMutatedSet(txn.mutated, demoted)
560565
return demoted
561566
default:
562567
parent = txn.cloneNode(parent)

0 commit comments

Comments
 (0)