Compare commits
2 Commits
587874841f
...
45da8fb996
| Author | SHA1 | Date | |
|---|---|---|---|
| 45da8fb996 | |||
| 4958a4cced |
@@ -1850,8 +1850,8 @@ bool scan16(const InternalVersionT *vs, const uint8_t *is, int begin, int end,
|
|||||||
// Returns true if v[i] <= readVersion for all i such that begin <= i < end
|
// Returns true if v[i] <= readVersion for all i such that begin <= i < end
|
||||||
//
|
//
|
||||||
// always_inline So that we can optimize when begin or end is a constant.
|
// always_inline So that we can optimize when begin or end is a constant.
|
||||||
__attribute((always_inline)) bool scan16(const InternalVersionT *vs, int begin,
|
inline __attribute((always_inline)) bool scan16(const InternalVersionT *vs,
|
||||||
int end,
|
int begin, int end,
|
||||||
InternalVersionT readVersion) {
|
InternalVersionT readVersion) {
|
||||||
assert(0 <= begin && begin < 16);
|
assert(0 <= begin && begin < 16);
|
||||||
assert(0 <= end && end <= 16);
|
assert(0 <= end && end <= 16);
|
||||||
@@ -1923,29 +1923,34 @@ bool checkMaxBetweenExclusive(Node *n, int begin, int end,
|
|||||||
// [begin, end) is now the half-open interval of children we're interested in.
|
// [begin, end) is now the half-open interval of children we're interested in.
|
||||||
assert(begin < end);
|
assert(begin < end);
|
||||||
|
|
||||||
const unsigned shiftUpperBound = end - begin;
|
|
||||||
const unsigned shiftAmount = begin;
|
|
||||||
auto inBounds = [&](unsigned c) { return c - shiftAmount < shiftUpperBound; };
|
|
||||||
|
|
||||||
switch (n->getType()) {
|
switch (n->getType()) {
|
||||||
case Type_Node0: // GCOVR_EXCL_LINE
|
case Type_Node0: // GCOVR_EXCL_LINE
|
||||||
// We would have returned above, after not finding a child
|
// We would have returned above, after not finding a child
|
||||||
__builtin_unreachable(); // GCOVR_EXCL_LINE
|
__builtin_unreachable(); // GCOVR_EXCL_LINE
|
||||||
case Type_Node3: {
|
case Type_Node3: {
|
||||||
auto *self = static_cast<Node3 *>(n);
|
auto *self = static_cast<Node3 *>(n);
|
||||||
bool result = true;
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
const unsigned shiftUpperBound = end - begin;
|
||||||
result &= !((self->childMaxVersion[i] > readVersion) &&
|
const unsigned shiftAmount = begin;
|
||||||
inBounds(self->index[i]));
|
auto inBounds = [&](unsigned c) {
|
||||||
|
return c - shiftAmount < shiftUpperBound;
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32_t compared = 0;
|
||||||
|
for (int i = 0; i < Node3::kMaxNodes; ++i) {
|
||||||
|
compared |= (self->childMaxVersion[i] > readVersion) << i;
|
||||||
|
}
|
||||||
|
uint32_t mask = 0;
|
||||||
|
for (int i = 0; i < Node3::kMaxNodes; ++i) {
|
||||||
|
mask |= inBounds(self->index[i]) << i;
|
||||||
|
}
|
||||||
|
return !(compared & mask);
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
} break;
|
|
||||||
case Type_Node16: {
|
case Type_Node16: {
|
||||||
auto *self = static_cast<Node16 *>(n);
|
auto *self = static_cast<Node16 *>(n);
|
||||||
|
|
||||||
return scan16(self->childMaxVersion, self->index, begin, end, readVersion);
|
return scan16(self->childMaxVersion, self->index, begin, end, readVersion);
|
||||||
|
}
|
||||||
} break;
|
|
||||||
case Type_Node48: {
|
case Type_Node48: {
|
||||||
auto *self = static_cast<Node48 *>(n);
|
auto *self = static_cast<Node48 *>(n);
|
||||||
// Check all pages
|
// Check all pages
|
||||||
|
|||||||
Reference in New Issue
Block a user