From 0c8cb8faa5f450a8763cb76db8a610c3b0bac006 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Fri, 8 Mar 2024 14:01:56 -0800 Subject: [PATCH] Add specializations for partialKey() --- .pre-commit-config.yaml | 8 -------- ConflictSet.cpp | 15 ++++++++++----- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5f3fcc1..2f9c120 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,12 +15,4 @@ repos: description: disallow checking in DEBUG_VERBOSE=1 entry: '^#define DEBUG_VERBOSE 1$' language: pygrep - types: [c++] - - repo: local - hooks: - - id: debug verbose check - name: disallow checking in SHOW_MEMORY=1 - description: disallow checking in SHOW_MEMORY=1 - entry: '^#define SHOW_MEMORY 1$' - language: pygrep types: [c++] \ No newline at end of file diff --git a/ConflictSet.cpp b/ConflictSet.cpp index ff62190..e0856b8 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -200,6 +200,7 @@ struct Node0 : Node { uint8_t index[16]; // 16 so that we can use the same simd index search // implementation as Node16 Node0() { this->type = Type::Node0; } + uint8_t *partialKey() { return (uint8_t *)(this + 1); } }; struct Node4 : Node { @@ -208,6 +209,7 @@ struct Node4 : Node { // implementation as Node16 Child children[4]; Node4() { this->type = Type::Node4; } + uint8_t *partialKey() { return (uint8_t *)(this + 1); } }; struct Node16 : Node { @@ -215,6 +217,7 @@ struct Node16 : Node { uint8_t index[16]; Child children[16]; Node16() { this->type = Type::Node16; } + uint8_t *partialKey() { return (uint8_t *)(this + 1); } }; struct Node48 : Node { @@ -226,6 +229,7 @@ struct Node48 : Node { memset(index, -1, 256); this->type = Type::Node48; } + uint8_t *partialKey() { return (uint8_t *)(this + 1); } }; struct Node256 : Node { @@ -237,6 +241,7 @@ struct Node256 : Node { children[i].child = nullptr; } } + uint8_t *partialKey() { return (uint8_t *)(this + 1); } }; template NodeT *newNode(int partialKeyCapacity) { @@ -250,15 +255,15 @@ template NodeT *newNode(int partialKeyCapacity) { uint8_t *Node::partialKey() { switch (type) { case Type::Node0: - return (uint8_t *)((Node0 *)this + 1); + return ((Node0 *)this)->partialKey(); case Type::Node4: - return (uint8_t *)((Node4 *)this + 1); + return ((Node4 *)this)->partialKey(); case Type::Node16: - return (uint8_t *)((Node16 *)this + 1); + return ((Node16 *)this)->partialKey(); case Type::Node48: - return (uint8_t *)((Node48 *)this + 1); + return ((Node48 *)this)->partialKey(); case Type::Node256: - return (uint8_t *)((Node256 *)this + 1); + return ((Node256 *)this)->partialKey(); } }