From f84aa88202807f811723ff1c29e47eb389eb3294 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Fri, 23 Feb 2024 13:31:05 -0800 Subject: [PATCH] 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 --- ConflictSet.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 4a7aac8..e29094a 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -1419,12 +1419,13 @@ bool checkRangeRead(Node *n, std::span 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;