Revert 303b368fc5
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.
This commit is contained in:
@@ -1087,7 +1087,6 @@ void maybeDecreaseCapacity(Node *&self, NodeAllocators *allocators,
|
||||
allocators, impl);
|
||||
}
|
||||
|
||||
template <Type kType>
|
||||
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<Type_Node3>(self, allocators, impl, result);
|
||||
break;
|
||||
case Type_Node16:
|
||||
maybeDownsize<Type_Node16>(self, allocators, impl, result);
|
||||
break;
|
||||
case Type_Node48:
|
||||
maybeDownsize<Type_Node48>(self, allocators, impl, result);
|
||||
break;
|
||||
case Type_Node256:
|
||||
maybeDownsize<Type_Node256>(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<Type_Node3>(parent, allocators, impl, result);
|
||||
if (update) {
|
||||
dontInvalidate = result;
|
||||
}
|
||||
} break;
|
||||
case Type_Node16: {
|
||||
auto *parent16 = static_cast<Node16 *>(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<Type_Node16>(parent, allocators, impl, result);
|
||||
if (update) {
|
||||
dontInvalidate = result;
|
||||
}
|
||||
|
||||
} break;
|
||||
case Type_Node48: {
|
||||
auto *parent48 = static_cast<Node48 *>(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<Type_Node48>(parent, allocators, impl, result);
|
||||
if (update) {
|
||||
dontInvalidate = result;
|
||||
}
|
||||
} break;
|
||||
case Type_Node256: {
|
||||
auto *parent256 = static_cast<Node256 *>(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<Type_Node256>(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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user