Skip to content

Commit

Permalink
fix race
Browse files Browse the repository at this point in the history
  • Loading branch information
absolutelightning committed May 29, 2024
1 parent e367a27 commit 9739749
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,13 @@ func (t *Txn[T]) removeChild4(n Node[T], c byte) Node[T] {
})
t.trackChannel(n.getChild(pos))

n.setNumChildren(n.getNumChildren() - 1)
copy(n.getKeys()[pos:], n.getKeys()[pos+1:])
children := n.getChildren()
copy(children[pos:], children[pos+1:])
n.setNumChildren(n.getNumChildren() - 1)
for itr := 0; itr < int(n.getNumChildren()); itr++ {
n.setChild(itr, children[itr])
}
n.setNumChildren(n.getNumChildren() - 1)

// Remove nodes with only a single child
if n.getNumChildren() == 1 {
Expand Down Expand Up @@ -402,10 +401,10 @@ func (t *Txn[T]) removeChild16(n Node[T], c byte) Node[T] {
copy(n.getKeys()[pos:], n.getKeys()[pos+1:])
children := n.getChildren()
copy(children[pos:], children[pos+1:])
n.setNumChildren(n.getNumChildren() - 1)
for itr := 0; itr < int(n.getNumChildren()); itr++ {
n.setChild(itr, children[itr])
}
n.setNumChildren(n.getNumChildren() - 1)

if n.getNumChildren() == 3 {
n.incrementLazyRefCount(-1)
Expand Down

0 comments on commit 9739749

Please sign in to comment.