Copy old node to new more efficiently

Presumably it's generating good code for the memcpy with a static size,
and hopefully also eliminating redundant stores
This commit is contained in:
2024-02-23 13:31:05 -08:00
parent 921da1cb3f
commit f84aa88202

View File

@@ -1419,12 +1419,13 @@ bool checkRangeRead(Node *n, std::span<const uint8_t> begin,
longestCommonPrefixPartialKey(self->partialKey, key.data(), commonLen);
if (partialKeyIndex < self->partialKeyLen) {
auto *old = self;
self = allocators->node4.allocate();
self->maxVersion = old->maxVersion;
memcpy((void *)self, old, offsetof(Node, type));
self->partialKeyLen = partialKeyIndex;
self->parent = old->parent;
self->parentsIndex = old->parentsIndex;
memcpy(self->partialKey, old->partialKey, partialKeyIndex);
self->entryPresent = false;
self->numChildren = 0;
getOrCreateChild(self, old->partialKey[partialKeyIndex], allocators) =
old;