From cdf9a8a7b075266acad08c7858def31ad0df43b8 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Tue, 20 Aug 2024 10:30:07 -0700 Subject: [PATCH] Save 8 bytes in Node3 --- ConflictSet.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index dafcad7..e087126 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -231,10 +231,10 @@ struct Node3 : Node { constexpr static auto kMaxNodes = 3; constexpr static auto kType = Type_Node3; - // Sorted - uint8_t index[kMaxNodes]; Node *children[kMaxNodes]; InternalVersionT childMaxVersion[kMaxNodes]; + // Sorted + uint8_t index[kMaxNodes]; uint8_t *partialKey() { return (uint8_t *)(this + 1); } void copyChildrenAndKeyFrom(const Node0 &other); @@ -247,10 +247,10 @@ struct Node16 : Node { constexpr static auto kType = Type_Node16; constexpr static auto kMaxNodes = 16; - // Sorted - uint8_t index[kMaxNodes]; Node *children[kMaxNodes]; InternalVersionT childMaxVersion[kMaxNodes]; + // Sorted + uint8_t index[kMaxNodes]; uint8_t *partialKey() { return (uint8_t *)(this + 1); } void copyChildrenAndKeyFrom(const Node3 &other); @@ -321,7 +321,7 @@ inline void Node3::copyChildrenAndKeyFrom(const Node0 &other) { inline void Node3::copyChildrenAndKeyFrom(const Node3 &other) { memcpy((char *)this + kNodeCopyBegin, (char *)&other + kNodeCopyBegin, kNodeCopySize); - memcpy(index, other.index, sizeof(*this) - sizeof(Node)); + memcpy(children, other.children, sizeof(*this) - sizeof(Node)); memcpy(partialKey(), &other + 1, partialKeyLen); for (int i = 0; i < numChildren; ++i) { assert(children[i]->parent == &other);