Stop tracking first iteration
We can tell with other means
This commit is contained in:
@@ -2507,7 +2507,9 @@ bool checkRangeRightSide(Node *n, std::span<const uint8_t> key, int prefixLen,
|
||||
}
|
||||
}
|
||||
|
||||
for (bool first = true;; first = false) {
|
||||
Node *commonPrefixNode = n;
|
||||
|
||||
for (;;) {
|
||||
Node *child = getChild(n, remaining[0]);
|
||||
if (child == nullptr) {
|
||||
auto c = getChildGeq(n, remaining[0]);
|
||||
@@ -2515,7 +2517,7 @@ bool checkRangeRightSide(Node *n, std::span<const uint8_t> key, int prefixLen,
|
||||
n = c;
|
||||
goto downLeftSpine;
|
||||
} else {
|
||||
if (!first && maxVersion(n) > readVersion) {
|
||||
if (n != commonPrefixNode && maxVersion(n) > readVersion) {
|
||||
return false;
|
||||
}
|
||||
goto backtrack;
|
||||
@@ -2533,11 +2535,12 @@ bool checkRangeRightSide(Node *n, std::span<const uint8_t> key, int prefixLen,
|
||||
if (c > 0) {
|
||||
goto downLeftSpine;
|
||||
} else {
|
||||
if ((!first || i + 1 >= prefixLen) && n->entryPresent &&
|
||||
n->entry.rangeVersion > readVersion) {
|
||||
if ((n->parent != commonPrefixNode || i + 1 >= prefixLen) &&
|
||||
n->entryPresent && n->entry.rangeVersion > readVersion) {
|
||||
return false;
|
||||
}
|
||||
if ((!first || i + 1 >= prefixLen) && maxVersion(n) > readVersion) {
|
||||
if ((n->parent != commonPrefixNode || i + 1 >= prefixLen) &&
|
||||
maxVersion(n) > readVersion) {
|
||||
return false;
|
||||
}
|
||||
goto backtrack;
|
||||
@@ -3280,21 +3283,16 @@ static Continuation commonPrefixIterTable[] = {
|
||||
common_prefix_iter<Node16>, common_prefix_iter<Node48>,
|
||||
common_prefix_iter<Node256>};
|
||||
|
||||
template <class NodeT, bool kFirst>
|
||||
template <class NodeT>
|
||||
PRESERVE_NONE void left_side_iter(CheckJob *, CheckContext *);
|
||||
|
||||
PRESERVE_NONE void left_side_down_left_spine(CheckJob *, CheckContext *);
|
||||
|
||||
PRESERVE_NONE void done_left_side_iter(CheckJob *, CheckContext *);
|
||||
|
||||
static Continuation leftSideIterTable[2][5] = {
|
||||
{left_side_iter<Node0, false>, left_side_iter<Node3, false>,
|
||||
left_side_iter<Node16, false>, left_side_iter<Node48, false>,
|
||||
left_side_iter<Node256, false>},
|
||||
{left_side_iter<Node0, true>, left_side_iter<Node3, true>,
|
||||
left_side_iter<Node16, true>, left_side_iter<Node48, true>,
|
||||
left_side_iter<Node256, true>},
|
||||
};
|
||||
static Continuation leftSideIterTable[] = {
|
||||
left_side_iter<Node0>, left_side_iter<Node3>, left_side_iter<Node16>,
|
||||
left_side_iter<Node48>, left_side_iter<Node256>};
|
||||
|
||||
PRESERVE_NONE void begin(CheckJob *job, CheckContext *context) {
|
||||
job->lcp = longestCommonPrefix(job->begin.data(), job->end.data(),
|
||||
@@ -3435,14 +3433,14 @@ PRESERVE_NONE void done_common_prefix_iter(CheckJob *job,
|
||||
}
|
||||
|
||||
job->n = child;
|
||||
job->continuation = leftSideIterTable[true][c.getType()];
|
||||
job->continuation = leftSideIterTable[c.getType()];
|
||||
__builtin_prefetch(job->n);
|
||||
MUSTTAIL return keepGoing(job, context);
|
||||
}
|
||||
|
||||
// Return true if the max version among all keys that start with key[:prefixLen]
|
||||
// that are >= key is <= readVersion
|
||||
template <class NodeT, bool kFirst>
|
||||
template <class NodeT>
|
||||
PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
||||
assert(NodeT::kType == job->n->getType());
|
||||
NodeT *n = static_cast<NodeT *>(job->n);
|
||||
@@ -3456,7 +3454,7 @@ PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
||||
if (i < commonLen) {
|
||||
auto c = n->partialKey()[i] <=> job->remaining[i];
|
||||
if (c > 0) {
|
||||
if constexpr (kFirst) {
|
||||
if (n->parent == job->commonPrefixNode) {
|
||||
if (i < job->lcp) {
|
||||
job->continuation = left_side_down_left_spine;
|
||||
MUSTTAIL return job->continuation(job, context);
|
||||
@@ -3541,7 +3539,7 @@ PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
||||
}
|
||||
|
||||
job->n = child;
|
||||
job->continuation = leftSideIterTable[false][c.getType()];
|
||||
job->continuation = leftSideIterTable[c.getType()];
|
||||
__builtin_prefetch(job->n);
|
||||
MUSTTAIL return keepGoing(job, context);
|
||||
}
|
||||
|
Reference in New Issue
Block a user