Minor improvements to checkMaxBetweenExclusive
This commit is contained in:
@@ -532,7 +532,7 @@ template <class T> struct BoundedFreeListAllocator {
|
|||||||
static_assert(std::derived_from<T, Node>);
|
static_assert(std::derived_from<T, Node>);
|
||||||
static_assert(std::is_trivial_v<T>);
|
static_assert(std::is_trivial_v<T>);
|
||||||
|
|
||||||
T *allocate(int partialKeyCapacity) {
|
T *allocate_helper(int partialKeyCapacity) {
|
||||||
if (freeList != nullptr) {
|
if (freeList != nullptr) {
|
||||||
T *n = (T *)freeList;
|
T *n = (T *)freeList;
|
||||||
VALGRIND_MAKE_MEM_DEFINED(freeList, sizeof(freeList));
|
VALGRIND_MAKE_MEM_DEFINED(freeList, sizeof(freeList));
|
||||||
@@ -560,6 +560,14 @@ template <class T> struct BoundedFreeListAllocator {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
T *allocate(int partialKeyCapacity) {
|
||||||
|
T *result = allocate_helper(partialKeyCapacity);
|
||||||
|
if constexpr (std::is_same_v<T, Node3> || std::is_same_v<T, Node16>) {
|
||||||
|
memset(result->children, 0, sizeof(result->children));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void release(T *p) {
|
void release(T *p) {
|
||||||
if (freeListBytes >= kFreeListMaxMemory) {
|
if (freeListBytes >= kFreeListMaxMemory) {
|
||||||
removeNode(p);
|
removeNode(p);
|
||||||
@@ -1652,37 +1660,31 @@ bool checkMaxBetweenExclusive(Node *n, int begin, int end,
|
|||||||
__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);
|
||||||
for (int i = 0; i < self->numChildren && self->index[i] < end; ++i) {
|
bool result = true;
|
||||||
if (begin <= self->index[i]) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
if (self->children[i].childMaxVersion > readVersion) {
|
result &= !((self->children[i].childMaxVersion > readVersion) &
|
||||||
return false;
|
(begin <= self->index[i]) & (self->index[i] < end));
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
} break;
|
} break;
|
||||||
case Type_Node16: {
|
case Type_Node16: {
|
||||||
auto *self = static_cast<Node16 *>(n);
|
auto *self = static_cast<Node16 *>(n);
|
||||||
for (int i = 0; i < self->numChildren && self->index[i] < end; ++i) {
|
bool result = true;
|
||||||
if (begin <= self->index[i]) {
|
for (int i = 0; i < 16; ++i) {
|
||||||
if (self->children[i].childMaxVersion > readVersion) {
|
result &= !((self->children[i].childMaxVersion > readVersion) &
|
||||||
return false;
|
(begin <= self->index[i]) & (self->index[i] < end));
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
} break;
|
} break;
|
||||||
case Type_Node48: {
|
case Type_Node48: {
|
||||||
bool conflict[256] = {};
|
|
||||||
auto *self = static_cast<Node48 *>(n);
|
auto *self = static_cast<Node48 *>(n);
|
||||||
|
bool result = true;
|
||||||
self->bitSet.forEachInRange(
|
self->bitSet.forEachInRange(
|
||||||
[&](int i) {
|
[&](int i) {
|
||||||
conflict[i] =
|
result &=
|
||||||
self->children[self->index[i]].childMaxVersion > readVersion;
|
self->children[self->index[i]].childMaxVersion <= readVersion;
|
||||||
},
|
},
|
||||||
begin, end);
|
begin, end);
|
||||||
bool result = true;
|
|
||||||
for (auto c : conflict) {
|
|
||||||
result &= !c;
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
case Type_Node256: {
|
case Type_Node256: {
|
||||||
@@ -1693,6 +1695,7 @@ bool checkMaxBetweenExclusive(Node *n, int begin, int end,
|
|||||||
conflict[i] = self->children[i].childMaxVersion > readVersion;
|
conflict[i] = self->children[i].childMaxVersion > readVersion;
|
||||||
},
|
},
|
||||||
begin, end);
|
begin, end);
|
||||||
|
// Should be vectorized
|
||||||
bool result = true;
|
bool result = true;
|
||||||
for (auto c : conflict) {
|
for (auto c : conflict) {
|
||||||
result &= !c;
|
result &= !c;
|
||||||
|
Reference in New Issue
Block a user