Non-recursive insert
This commit is contained in:
@@ -905,14 +905,16 @@ void debugPrintDot(FILE *file, Node *node) {
|
|||||||
fprintf(file, "}\n");
|
fprintf(file, "}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static Node *insert(Node *&self, std::span<const uint8_t> key,
|
static void insert(Node **self_, std::span<const uint8_t> key,
|
||||||
int64_t writeVersion) {
|
int64_t writeVersion) {
|
||||||
|
for (;;) {
|
||||||
|
auto &self = *self_;
|
||||||
self->maxVersion = writeVersion;
|
self->maxVersion = writeVersion;
|
||||||
if (key.size() == 0) {
|
if (key.size() == 0) {
|
||||||
self->entryPresent = true;
|
self->entryPresent = true;
|
||||||
self->entry.pointVersion = writeVersion;
|
self->entry.pointVersion = writeVersion;
|
||||||
// TODO set correct rangeVersion
|
// TODO set correct rangeVersion
|
||||||
return self;
|
return;
|
||||||
}
|
}
|
||||||
auto &child = getOrCreateChild(self, key.front());
|
auto &child = getOrCreateChild(self, key.front());
|
||||||
if (!child) {
|
if (!child) {
|
||||||
@@ -920,7 +922,9 @@ static Node *insert(Node *&self, std::span<const uint8_t> key,
|
|||||||
child->parent = self;
|
child->parent = self;
|
||||||
child->parentsIndex = key.front();
|
child->parentsIndex = key.front();
|
||||||
}
|
}
|
||||||
return insert(child, key.subspan(1, key.size() - 1), writeVersion);
|
self_ = &child;
|
||||||
|
key = key.subspan(1, key.size() - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
|
struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
|
||||||
@@ -930,7 +934,7 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
|
|||||||
const auto &w = writes[i];
|
const auto &w = writes[i];
|
||||||
// TODO support non-point writes
|
// TODO support non-point writes
|
||||||
assert(w.end.len == 0);
|
assert(w.end.len == 0);
|
||||||
insert(root, std::span<const uint8_t>(w.begin.p, w.begin.len),
|
insert(&root, std::span<const uint8_t>(w.begin.p, w.begin.len),
|
||||||
w.writeVersion);
|
w.writeVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user