From ce79b47fbea6948d60d3d1a5d5925a23ae22b10f Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Tue, 19 Mar 2024 15:01:13 -0700 Subject: [PATCH] Revert 303b368fc505df275d9707bc43a8afd89d36f9e7 This is a code-size / speed tradeoff. Maybe it's a good idea here, but it's a bit weird to do this in some places and not others (there are many places we can avoid switching on type this way). The compiler can inline and then dead code eliminate to achieve the same effect, so we'll just let the compiler be in charge of inlining decisions. --- ConflictSet.cpp | 53 ++++++++----------------------------------------- 1 file changed, 8 insertions(+), 45 deletions(-) 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; }