Factor out "maxRightOf"
This commit is contained in:
@@ -919,6 +919,16 @@ descend(int &depth, int &lcp, Node *newNode, std::span<const uint8_t> end,
|
|||||||
newNode->partialKey + newNode->partialKeyLen);
|
newNode->partialKey + newNode->partialKeyLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Precondition: node has a child at index begin
|
||||||
|
int64_t maxRightOf(Node *n, int begin) {
|
||||||
|
int64_t result = std::numeric_limits<int64_t>::lowest();
|
||||||
|
while (begin >= 0) {
|
||||||
|
result = std::max(result, getChildExists(n, begin)->maxVersion);
|
||||||
|
begin = getChildGeq(n, begin + 1);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
bool checkRangeRead(Node *n, const std::span<const uint8_t> begin,
|
bool checkRangeRead(Node *n, const std::span<const uint8_t> begin,
|
||||||
const std::span<const uint8_t> end, int64_t readVersion,
|
const std::span<const uint8_t> end, int64_t readVersion,
|
||||||
Arena &arena) {
|
Arena &arena) {
|
||||||
@@ -1039,11 +1049,8 @@ bool checkRangeRead(Node *n, const std::span<const uint8_t> begin,
|
|||||||
fprintf(stderr, "%s, right of %02x\n",
|
fprintf(stderr, "%s, right of %02x\n",
|
||||||
printable(searchPath).c_str(), next);
|
printable(searchPath).c_str(), next);
|
||||||
#endif
|
#endif
|
||||||
while (next >= 0) {
|
if (maxRightOf(iter, next) > readVersion) {
|
||||||
if (getChildExists(iter, next)->maxVersion > readVersion) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
next = getChildGeq(iter, next + 1);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
iter = getChildExists(iter, next);
|
iter = getChildExists(iter, next);
|
||||||
|
Reference in New Issue
Block a user