From 305dfdd52ff5f1125b456bcc8dfe015d56f5a623 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Tue, 20 Aug 2024 09:57:44 -0700 Subject: [PATCH] Change whitespace in node structs for consistency --- ConflictSet.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 1604587..dafcad7 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -197,7 +197,6 @@ struct Node { /* end section that's copied to the next node */ uint8_t *partialKey(); - Type getType() const { return type; } int32_t getCapacity() const { return partialKeyCapacity; } @@ -221,43 +220,42 @@ constexpr int kNodeCopySize = struct Node0 : Node { constexpr static auto kType = Type_Node0; - uint8_t *partialKey() { return (uint8_t *)(this + 1); } + uint8_t *partialKey() { return (uint8_t *)(this + 1); } void copyChildrenAndKeyFrom(const Node0 &other); void copyChildrenAndKeyFrom(const struct Node3 &other); - size_t size() const { return sizeof(Node0) + getCapacity(); } }; 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]; - uint8_t *partialKey() { return (uint8_t *)(this + 1); } + uint8_t *partialKey() { return (uint8_t *)(this + 1); } void copyChildrenAndKeyFrom(const Node0 &other); void copyChildrenAndKeyFrom(const Node3 &other); void copyChildrenAndKeyFrom(const struct Node16 &other); - size_t size() const { return sizeof(Node3) + getCapacity(); } }; 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]; - uint8_t *partialKey() { return (uint8_t *)(this + 1); } + uint8_t *partialKey() { return (uint8_t *)(this + 1); } void copyChildrenAndKeyFrom(const Node3 &other); void copyChildrenAndKeyFrom(const Node16 &other); void copyChildrenAndKeyFrom(const struct Node48 &other); - size_t size() const { return sizeof(Node16) + getCapacity(); } }; @@ -277,28 +275,28 @@ struct Node48 : Node { int8_t index[256]; uint8_t *partialKey() { return (uint8_t *)(this + 1); } - void copyChildrenAndKeyFrom(const Node16 &other); void copyChildrenAndKeyFrom(const Node48 &other); void copyChildrenAndKeyFrom(const struct Node256 &other); - size_t size() const { return sizeof(Node48) + getCapacity(); } }; struct Node256 : Node { constexpr static auto kType = Type_Node256; - BitSet bitSet; - Node *children[256]; - InternalVersionT childMaxVersion[256]; + constexpr static auto kMaxNodes = 256; constexpr static int kMaxOfMaxPageSize = 16; constexpr static int kMaxOfMaxShift = std::countr_zero(uint32_t(kMaxOfMaxPageSize)); - constexpr static int kMaxOfMaxTotalPages = 256 / kMaxOfMaxPageSize; + constexpr static int kMaxOfMaxTotalPages = kMaxNodes / kMaxOfMaxPageSize; + + BitSet bitSet; + Node *children[kMaxNodes]; + InternalVersionT childMaxVersion[kMaxNodes]; InternalVersionT maxOfMax[kMaxOfMaxTotalPages]; + uint8_t *partialKey() { return (uint8_t *)(this + 1); } void copyChildrenAndKeyFrom(const Node48 &other); void copyChildrenAndKeyFrom(const Node256 &other); - size_t size() const { return sizeof(Node256) + getCapacity(); } };