Simplify insert loop

This commit is contained in:
2024-08-12 16:25:12 -07:00
parent 1c9dda68a6
commit 54e47ebd40

View File

@@ -2798,20 +2798,10 @@ Node **insert(Node **self, std::span<const uint8_t> key,
assert(maxVersion(*self, impl) <= writeVersion);
setMaxVersion(*self, impl, writeVersion);
for (;; ++tls->accum.insert_iterations) {
if (key.size() == 0) {
return self;
}
bool existed = getChild(*self, key.front());
auto &child = getOrCreateChild(*self, key, writeVersion, tls);
if (!existed) {
return &child;
}
self = &child;
for (; key.size() != 0; ++tls->accum.insert_iterations) {
self = &getOrCreateChild(*self, key, writeVersion, tls);
}
return self;
}
void destroyTree(Node *root) {