diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 5a83c1c..6b48747 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -1087,7 +1087,6 @@ void maybeDecreaseCapacity(Node *&self, NodeAllocators *allocators, allocators, impl); } -template void maybeDownsize(Node *self, NodeAllocators *allocators, ConflictSet::Impl *impl, Node *&dontInvalidate) { @@ -1095,9 +1094,7 @@ void maybeDownsize(Node *self, NodeAllocators *allocators, fprintf(stderr, "maybeDownsize: %s\n", getSearchPathPrintable(self).c_str()); #endif - assert(self->getType() == kType); - static_assert(kType != Type_Node0); - switch (kType) { + switch (self->getType()) { case Type_Node0: // GCOVR_EXCL_LINE __builtin_unreachable(); // GCOVR_EXCL_LINE case Type_Node3: { @@ -1201,24 +1198,7 @@ Node *erase(Node *self, NodeAllocators *allocators, ConflictSet::Impl *impl, if (self->numChildren != 0) { const bool update = result == dontInvalidate; - switch (self->getType()) { - case Type_Node0: // GCOVR_EXCL_LINE - __builtin_unreachable(); // GCOVR_EXCL_LINE - case Type_Node3: - maybeDownsize(self, allocators, impl, result); - break; - case Type_Node16: - maybeDownsize(self, allocators, impl, result); - break; - case Type_Node48: - maybeDownsize(self, allocators, impl, result); - break; - case Type_Node256: - maybeDownsize(self, allocators, impl, result); - break; - default: // GCOVR_EXCL_LINE - __builtin_unreachable(); // GCOVR_EXCL_LINE - } + maybeDownsize(self, allocators, impl, result); if (update) { dontInvalidate = result; } @@ -1244,11 +1224,6 @@ Node *erase(Node *self, NodeAllocators *allocators, ConflictSet::Impl *impl, --parent->numChildren; assert(parent->numChildren > 0 || parent->entryPresent); - const bool update = result == dontInvalidate; - maybeDownsize(parent, allocators, impl, result); - if (update) { - dontInvalidate = result; - } } break; case Type_Node16: { auto *parent16 = static_cast(parent); @@ -1265,13 +1240,6 @@ Node *erase(Node *self, NodeAllocators *allocators, ConflictSet::Impl *impl, // By kMinChildrenNode16 assert(parent->numChildren > 0); - - const bool update = result == dontInvalidate; - maybeDownsize(parent, allocators, impl, result); - if (update) { - dontInvalidate = result; - } - } break; case Type_Node48: { auto *parent48 = static_cast(parent); @@ -1292,12 +1260,6 @@ Node *erase(Node *self, NodeAllocators *allocators, ConflictSet::Impl *impl, // By kMinChildrenNode48 assert(parent->numChildren > 0); - - const bool update = result == dontInvalidate; - maybeDownsize(parent, allocators, impl, result); - if (update) { - dontInvalidate = result; - } } break; case Type_Node256: { auto *parent256 = static_cast(parent); @@ -1309,16 +1271,17 @@ Node *erase(Node *self, NodeAllocators *allocators, ConflictSet::Impl *impl, // By kMinChildrenNode256 assert(parent->numChildren > 0); - const bool update = result == dontInvalidate; - maybeDownsize(parent, allocators, impl, result); - if (update) { - dontInvalidate = result; - } } break; default: // GCOVR_EXCL_LINE __builtin_unreachable(); // GCOVR_EXCL_LINE } + const bool update = result == dontInvalidate; + maybeDownsize(parent, allocators, impl, result); + if (update) { + dontInvalidate = result; + } + return result; }