From 403d70a1d3d59ceb94f3ebf35e59206b203a44ec Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Thu, 15 Aug 2024 11:33:16 -0700 Subject: [PATCH] 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. --- ConflictSet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index ef73503..46aa484 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -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(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(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(n->partialKeyLen);