Prefer not copying node in eraseBetween
If numChildren + entryPresent is enough, we don't have to copy even if it would fit in a smaller node. If we have to copy, we might as well use the smallest acceptable node type.
This commit is contained in:
@@ -1827,7 +1827,7 @@ void eraseBetween(Node **inTree, Node16 *n, int begin, int end,
|
||||
n->index[i] = n->index[i + count];
|
||||
}
|
||||
|
||||
if (n->numChildren > Node3::kMaxNodes) {
|
||||
if (n->numChildren + n->entryPresent >= kMinChildrenNode16) {
|
||||
// nop
|
||||
} else if (n->numChildren > 0) {
|
||||
auto *newNode = tls->allocate<Node3>(n->partialKeyLen);
|
||||
@@ -1867,7 +1867,7 @@ void eraseBetween(Node **inTree, Node48 *n, int begin, int end,
|
||||
--n->numChildren;
|
||||
}
|
||||
|
||||
if (n->numChildren > Node16::kMaxNodes) {
|
||||
if (n->numChildren + n->entryPresent >= kMinChildrenNode48) {
|
||||
// nop
|
||||
} else if (n->numChildren > Node3::kMaxNodes) {
|
||||
auto *newNode = tls->allocate<Node16>(n->partialKeyLen);
|
||||
@@ -1896,7 +1896,7 @@ void eraseBetween(Node **inTree, Node256 *n, int begin, int end,
|
||||
n->bitSet.reset(i);
|
||||
--n->numChildren;
|
||||
}
|
||||
if (n->numChildren > Node48::kMaxNodes) {
|
||||
if (n->numChildren + n->entryPresent >= kMinChildrenNode256) {
|
||||
// nop
|
||||
} else if (n->numChildren > Node16::kMaxNodes) {
|
||||
auto *newNode = tls->allocate<Node48>(n->partialKeyLen);
|
||||
|
Reference in New Issue
Block a user