Remove some usages of maxVersion

This commit is contained in:
2024-11-20 21:18:12 -08:00
parent 0df2db7f8a
commit 7c01f8ba0f

View File

@@ -2670,7 +2670,8 @@ bool checkRangeStartsWith(NodeT *nTyped, TrivialSpan key, int begin, int end,
readContext); readContext);
} }
Node *child = getChild(nTyped, remaining[0]); auto cAndV = getChildAndMaxVersion(nTyped, remaining[0]);
Node *child = cAndV.child;
if (child == nullptr) { if (child == nullptr) {
auto c = getChildGeq(nTyped, remaining[0]); auto c = getChildGeq(nTyped, remaining[0]);
if (c != nullptr) { if (c != nullptr) {
@@ -2710,7 +2711,7 @@ bool checkRangeStartsWith(NodeT *nTyped, TrivialSpan key, int begin, int end,
if (n->entryPresent && n->entry.rangeVersion > readVersion) { if (n->entryPresent && n->entry.rangeVersion > readVersion) {
return false; return false;
} }
return maxVersion(n) <= readVersion; return cAndV.maxVersion <= readVersion;
} }
return true; return true;
} }
@@ -3567,8 +3568,8 @@ PRESERVE_NONE void done_common_prefix_iter(Job *job, Context *context) {
// This is a hack // This is a hack
--job->lcp; --job->lcp;
auto c = getChild(n, job->remaining[0]); auto cAndV = getChildAndMaxVersion(n, job->remaining[0]);
Node *child = c; Node *child = cAndV.child;
if (child == nullptr) { if (child == nullptr) {
auto c = getChildGeq(n, job->remaining[0]); auto c = getChildGeq(n, job->remaining[0]);
if (c != nullptr) { if (c != nullptr) {
@@ -3587,7 +3588,8 @@ PRESERVE_NONE void done_common_prefix_iter(Job *job, Context *context) {
} }
job->n = child; job->n = child;
job->continuation = rightSideIterTable[c.getType()]; job->maxV = cAndV.maxVersion;
job->continuation = rightSideIterTable[cAndV.child.getType()];
MUSTTAIL return keepGoing(job, context); MUSTTAIL return keepGoing(job, context);
} }
@@ -3732,8 +3734,8 @@ PRESERVE_NONE void done_left_side_iter(Job *job, Context *context) {
job->n = job->commonPrefixNode; job->n = job->commonPrefixNode;
job->remaining = job->end; job->remaining = job->end;
auto c = getChild(job->n, job->remaining[0]); auto cAndV = getChildAndMaxVersion(job->n, job->remaining[0]);
Node *child = c; Node *child = cAndV.child;
if (child == nullptr) { if (child == nullptr) {
auto c = getChildGeq(job->n, job->remaining[0]); auto c = getChildGeq(job->n, job->remaining[0]);
if (c != nullptr) { if (c != nullptr) {
@@ -3753,7 +3755,8 @@ PRESERVE_NONE void done_left_side_iter(Job *job, Context *context) {
} }
job->n = child; job->n = child;
job->continuation = rightSideIterTable[c.getType()]; job->maxV = cAndV.maxVersion;
job->continuation = rightSideIterTable[cAndV.child.getType()];
MUSTTAIL return keepGoing(job, context); MUSTTAIL return keepGoing(job, context);
} }
@@ -3799,7 +3802,7 @@ PRESERVE_NONE void right_side_iter(Job *job, Context *context) {
MUSTTAIL return complete(job, context); MUSTTAIL return complete(job, context);
} }
if ((n->parent != job->commonPrefixNode || i >= job->lcp) && if ((n->parent != job->commonPrefixNode || i >= job->lcp) &&
maxVersion(n) > job->readVersion) { job->maxV > job->readVersion) {
job->setResult(false); job->setResult(false);
MUSTTAIL return complete(job, context); MUSTTAIL return complete(job, context);
} }
@@ -3844,8 +3847,8 @@ PRESERVE_NONE void right_side_iter(Job *job, Context *context) {
MUSTTAIL return complete(job, context); MUSTTAIL return complete(job, context);
} }
auto c = getChild(job->n, job->remaining[0]); auto cAndV = getChildAndMaxVersion(job->n, job->remaining[0]);
Node *child = c; Node *child = cAndV.child;
if (child == nullptr) { if (child == nullptr) {
auto c = getChildGeq(n, job->remaining[0]); auto c = getChildGeq(n, job->remaining[0]);
if (c != nullptr) { if (c != nullptr) {
@@ -3865,7 +3868,8 @@ PRESERVE_NONE void right_side_iter(Job *job, Context *context) {
} }
job->n = child; job->n = child;
job->continuation = rightSideIterTable[c.getType()]; job->maxV = cAndV.maxVersion;
job->continuation = rightSideIterTable[cAndV.child.getType()];
MUSTTAIL return keepGoing(job, context); MUSTTAIL return keepGoing(job, context);
} }
@@ -4545,7 +4549,7 @@ bool checkPrefixRead(Node *n, const TrivialSpan key,
// n is the first physical node greater than remaining, and there's no // n is the first physical node greater than remaining, and there's no
// eq node. All physical nodes that start with prefix are reachable from // eq node. All physical nodes that start with prefix are reachable from
// n. // n.
if (maxVersion(n) > readVersion) { if (maxV > readVersion) {
return false; return false;
} }
goto downLeftSpine; goto downLeftSpine;
@@ -4620,7 +4624,7 @@ bool checkRangeLeftSide(Node *n, TrivialSpan key, int prefixLen,
if (n->entryPresent && n->entry.rangeVersion > readVersion) { if (n->entryPresent && n->entry.rangeVersion > readVersion) {
return false; return false;
} }
return maxVersion(n) <= readVersion; return maxV <= readVersion;
} else { } else {
n = nextSibling(n); n = nextSibling(n);
if (n == nullptr) { if (n == nullptr) {
@@ -4637,7 +4641,7 @@ bool checkRangeLeftSide(Node *n, TrivialSpan key, int prefixLen,
if (n->entryPresent && n->entry.rangeVersion > readVersion) { if (n->entryPresent && n->entry.rangeVersion > readVersion) {
return false; return false;
} }
return maxVersion(n) <= readVersion; return maxV <= readVersion;
} }
} }
if (maxV <= readVersion) { if (maxV <= readVersion) {