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;
|
||||
}
|
||||
|
||||
struct Iterator {
|
||||
Node *n;
|
||||
int cmp;
|
||||
};
|
||||
|
||||
Node *nextSibling(Node *node) {
|
||||
for (;;) {
|
||||
if (node->parent == nullptr) {
|
||||
@@ -3667,12 +3662,12 @@ double internal_getMetricValue(const ConflictSet::MetricsV1 *metric) {
|
||||
|
||||
// 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;
|
||||
for (;;) {
|
||||
if (remaining.size() == 0) {
|
||||
if (n->entryPresent) {
|
||||
return {n, 0};
|
||||
return n;
|
||||
}
|
||||
int c = getChildGeq(n, 0);
|
||||
assert(c >= 0);
|
||||
@@ -3689,7 +3684,7 @@ Iterator firstGeqLogical(Node *n, const std::span<const uint8_t> key) {
|
||||
} else {
|
||||
n = nextSibling(n);
|
||||
if (n == nullptr) {
|
||||
return {nullptr, 1};
|
||||
return nullptr;
|
||||
}
|
||||
goto downLeftSpine;
|
||||
}
|
||||
@@ -3721,14 +3716,9 @@ Iterator firstGeqLogical(Node *n, const std::span<const uint8_t> key) {
|
||||
}
|
||||
}
|
||||
downLeftSpine:
|
||||
for (;;) {
|
||||
if (n->entryPresent) {
|
||||
return {n, 1};
|
||||
}
|
||||
int c = getChildGeq(n, 0);
|
||||
assert(c >= 0);
|
||||
n = getChildExists(n, c);
|
||||
for (; !n->entryPresent; n = getFirstChildExists(n)) {
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
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(
|
||||
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);
|
||||
if (ok) {
|
||||
auto borrowed = firstGeq(root, inc);
|
||||
if (borrowed.n != nullptr) {
|
||||
expected = std::max(expected, borrowed.n->entry.rangeVersion);
|
||||
if (borrowed != nullptr) {
|
||||
expected = std::max(expected, borrowed->entry.rangeVersion);
|
||||
}
|
||||
}
|
||||
if (maxVersion(node, impl) > oldestVersion &&
|
||||
|
Reference in New Issue
Block a user