trie: reduce fullNode to valueNode with only index[16] after delete

This commit is contained in:
qinglin89 2023-01-12 11:51:58 +08:00
parent 793f0f9ec8
commit ee78e8037b
1 changed files with 3 additions and 1 deletions

View File

@ -472,7 +472,9 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
}
}
if pos >= 0 {
if pos != 16 {
if pos == 16 {
return true, n.Children[16].(valueNode), nil
} else {
// If the remaining entry is a short node, it replaces
// n and its key gets the missing nibble tacked to the
// front. This avoids creating an invalid