Skip to content

Commit

Permalink
fix(trie): descendants count for clear prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Jun 15, 2022
1 parent 7f55bec commit 6c50153
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/trie/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,10 +877,11 @@ func (t *Trie) clearPrefix(parent *Node, prefix []byte) (
return parent, nodesRemoved
}

nodesRemoved = 1
nodesRemoved = 1 + child.Descendants
copySettings := node.DefaultCopySettings
branch = t.prepBranchForMutation(branch, copySettings)
branch.Children[childIndex] = nil
branch.Descendants -= nodesRemoved
var branchChildMerged bool
newParent, branchChildMerged = handleDeletion(branch, prefix)
if branchChildMerged {
Expand All @@ -892,7 +893,7 @@ func (t *Trie) clearPrefix(parent *Node, prefix []byte) (
noPrefixForNode := len(prefix) <= len(branch.Key) ||
lenCommonPrefix(branch.Key, prefix) < len(branch.Key)
if noPrefixForNode {
const nodesRemoved = 0
const nodesRemoved = 0 // XXX
return parent, nodesRemoved
}

Expand Down

0 comments on commit 6c50153

Please sign in to comment.