Simplify remaining "down left spine" loops
This commit is contained in:
@@ -1680,11 +1680,6 @@ Node *erase(Node *self, WriteContext *tls, ConflictSet::Impl *impl,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Iterator {
|
|
||||||
Node *n;
|
|
||||||
int cmp;
|
|
||||||
};
|
|
||||||
|
|
||||||
Node *nextSibling(Node *node) {
|
Node *nextSibling(Node *node) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (node->parent == nullptr) {
|
if (node->parent == nullptr) {
|
||||||
@@ -3667,12 +3662,12 @@ double internal_getMetricValue(const ConflictSet::MetricsV1 *metric) {
|
|||||||
|
|
||||||
// GCOVR_EXCL_START
|
// GCOVR_EXCL_START
|
||||||
|
|
||||||
Iterator firstGeqLogical(Node *n, const std::span<const uint8_t> key) {
|
Node *firstGeqLogical(Node *n, const std::span<const uint8_t> key) {
|
||||||
auto remaining = key;
|
auto remaining = key;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (remaining.size() == 0) {
|
if (remaining.size() == 0) {
|
||||||
if (n->entryPresent) {
|
if (n->entryPresent) {
|
||||||
return {n, 0};
|
return n;
|
||||||
}
|
}
|
||||||
int c = getChildGeq(n, 0);
|
int c = getChildGeq(n, 0);
|
||||||
assert(c >= 0);
|
assert(c >= 0);
|
||||||
@@ -3689,7 +3684,7 @@ Iterator firstGeqLogical(Node *n, const std::span<const uint8_t> key) {
|
|||||||
} else {
|
} else {
|
||||||
n = nextSibling(n);
|
n = nextSibling(n);
|
||||||
if (n == nullptr) {
|
if (n == nullptr) {
|
||||||
return {nullptr, 1};
|
return nullptr;
|
||||||
}
|
}
|
||||||
goto downLeftSpine;
|
goto downLeftSpine;
|
||||||
}
|
}
|
||||||
@@ -3721,14 +3716,9 @@ Iterator firstGeqLogical(Node *n, const std::span<const uint8_t> key) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
downLeftSpine:
|
downLeftSpine:
|
||||||
for (;;) {
|
for (; !n->entryPresent; n = getFirstChildExists(n)) {
|
||||||
if (n->entryPresent) {
|
|
||||||
return {n, 1};
|
|
||||||
}
|
|
||||||
int c = getChildGeq(n, 0);
|
|
||||||
assert(c >= 0);
|
|
||||||
n = getChildExists(n, c);
|
|
||||||
}
|
}
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConflictSet::check(const ReadRange *reads, Result *results,
|
void ConflictSet::check(const ReadRange *reads, Result *results,
|
||||||
@@ -3935,7 +3925,7 @@ void checkParentPointers(Node *node, bool &success) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator firstGeq(Node *n, std::string_view key) {
|
Node *firstGeq(Node *n, std::string_view key) {
|
||||||
return firstGeqLogical(
|
return firstGeqLogical(
|
||||||
n, std::span<const uint8_t>((const uint8_t *)key.data(), key.size()));
|
n, std::span<const uint8_t>((const uint8_t *)key.data(), key.size()));
|
||||||
}
|
}
|
||||||
@@ -4006,8 +3996,8 @@ checkMaxVersion(Node *root, Node *node, InternalVersionT oldestVersion,
|
|||||||
auto inc = strinc(key, ok);
|
auto inc = strinc(key, ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
auto borrowed = firstGeq(root, inc);
|
auto borrowed = firstGeq(root, inc);
|
||||||
if (borrowed.n != nullptr) {
|
if (borrowed != nullptr) {
|
||||||
expected = std::max(expected, borrowed.n->entry.rangeVersion);
|
expected = std::max(expected, borrowed->entry.rangeVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (maxVersion(node, impl) > oldestVersion &&
|
if (maxVersion(node, impl) > oldestVersion &&
|
||||||
|
Reference in New Issue
Block a user