Use assume

It works now that we fell back to the __builtin_unreachable based
implementation for gcc.
This commit is contained in:
2024-03-15 17:23:02 -07:00
parent e7719b6e0b
commit dfbb3ce5f1

View File

@@ -374,10 +374,8 @@ inline void Node16::copyChildrenAndKeyFrom(const Node48 &other) {
other.bitSet.forEachInRange( other.bitSet.forEachInRange(
[&](int c) { [&](int c) {
// Suppress a false positive -Waggressive-loop-optimizations warning // Suppress a false positive -Waggressive-loop-optimizations warning
// in gcc. `assume` doesn't work for some reason. // in gcc
if (!(i < Node16::kMaxNodes)) { assume(i < Node16::kMaxNodes);
__builtin_unreachable(); // GCOVR_EXCL_LINE
}
index[i] = c; index[i] = c;
children[i] = other.children[other.index[c]]; children[i] = other.children[other.index[c]];
assert(children[i].child->parent == &other); assert(children[i].child->parent == &other);
@@ -430,10 +428,8 @@ inline void Node48::copyChildrenAndKeyFrom(const Node256 &other) {
bitSet.forEachInRange( bitSet.forEachInRange(
[&](int c) { [&](int c) {
// Suppress a false positive -Waggressive-loop-optimizations warning // Suppress a false positive -Waggressive-loop-optimizations warning
// in gcc. `assume` doesn't work for some reason. // in gcc.
if (!(i < Node48::kMaxNodes)) { assume(i < Node48::kMaxNodes);
__builtin_unreachable(); // GCOVR_EXCL_LINE
}
index[c] = i; index[c] = i;
children[i] = other.children[c]; children[i] = other.children[c];
assert(children[i].child->parent == &other); assert(children[i].child->parent == &other);