Maintain nextSib in firstGeq

This is slower, but I think it's closer to what we want for our eventual bespoke
"fused-check-and-search" implementation.
This commit is contained in:
2024-02-06 12:37:02 -08:00
parent 03e9dc01fd
commit 68239cd80b

View File

@@ -657,6 +657,7 @@ std::string getSearchPath(Node *n) {
Iterator firstGeq(Node *n, const std::span<const uint8_t> key) {
auto remaining = key;
Node *nextSib = nullptr;
for (;;) {
if (n->partialKeyLen > 0) {
int commonLen = std::min<int>(n->partialKeyLen, remaining.size());
@@ -668,7 +669,7 @@ Iterator firstGeq(Node *n, const std::span<const uint8_t> key) {
if (c > 0) {
goto downLeftSpine;
} else {
n = nextSibling(n);
n = nextSib;
goto downLeftSpine;
}
}
@@ -691,6 +692,10 @@ Iterator firstGeq(Node *n, const std::span<const uint8_t> key) {
goto downLeftSpine;
} else {
int c = getChildGeq(n, remaining[0]);
int c2 = getChildGeq(n, int(remaining[0]) + 1);
if (c2 >= 0) {
nextSib = getChildExists(n, c2);
}
if (c == remaining[0]) {
n = getChildExists(n, c);
remaining = remaining.subspan(1, remaining.size() - 1);
@@ -699,7 +704,7 @@ Iterator firstGeq(Node *n, const std::span<const uint8_t> key) {
n = getChildExists(n, c);
goto downLeftSpine;
} else {
n = nextSibling(n);
n = nextSib;
goto downLeftSpine;
}
}