From 68239cd80b7c70b1bf9038d23d8313b46a236304 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Tue, 6 Feb 2024 12:37:02 -0800 Subject: [PATCH] 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. --- ConflictSet.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 79705e6..0b94be9 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -657,6 +657,7 @@ std::string getSearchPath(Node *n) { Iterator firstGeq(Node *n, const std::span key) { auto remaining = key; + Node *nextSib = nullptr; for (;;) { if (n->partialKeyLen > 0) { int commonLen = std::min(n->partialKeyLen, remaining.size()); @@ -668,7 +669,7 @@ Iterator firstGeq(Node *n, const std::span 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 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 key) { n = getChildExists(n, c); goto downLeftSpine; } else { - n = nextSibling(n); + n = nextSib; goto downLeftSpine; } }