Add specializations for partialKey()
This commit is contained in:
@@ -16,11 +16,3 @@ repos:
|
|||||||
entry: '^#define DEBUG_VERBOSE 1$'
|
entry: '^#define DEBUG_VERBOSE 1$'
|
||||||
language: pygrep
|
language: pygrep
|
||||||
types: [c++]
|
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++]
|
|
@@ -200,6 +200,7 @@ struct Node0 : Node {
|
|||||||
uint8_t index[16]; // 16 so that we can use the same simd index search
|
uint8_t index[16]; // 16 so that we can use the same simd index search
|
||||||
// implementation as Node16
|
// implementation as Node16
|
||||||
Node0() { this->type = Type::Node0; }
|
Node0() { this->type = Type::Node0; }
|
||||||
|
uint8_t *partialKey() { return (uint8_t *)(this + 1); }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Node4 : Node {
|
struct Node4 : Node {
|
||||||
@@ -208,6 +209,7 @@ struct Node4 : Node {
|
|||||||
// implementation as Node16
|
// implementation as Node16
|
||||||
Child children[4];
|
Child children[4];
|
||||||
Node4() { this->type = Type::Node4; }
|
Node4() { this->type = Type::Node4; }
|
||||||
|
uint8_t *partialKey() { return (uint8_t *)(this + 1); }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Node16 : Node {
|
struct Node16 : Node {
|
||||||
@@ -215,6 +217,7 @@ struct Node16 : Node {
|
|||||||
uint8_t index[16];
|
uint8_t index[16];
|
||||||
Child children[16];
|
Child children[16];
|
||||||
Node16() { this->type = Type::Node16; }
|
Node16() { this->type = Type::Node16; }
|
||||||
|
uint8_t *partialKey() { return (uint8_t *)(this + 1); }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Node48 : Node {
|
struct Node48 : Node {
|
||||||
@@ -226,6 +229,7 @@ struct Node48 : Node {
|
|||||||
memset(index, -1, 256);
|
memset(index, -1, 256);
|
||||||
this->type = Type::Node48;
|
this->type = Type::Node48;
|
||||||
}
|
}
|
||||||
|
uint8_t *partialKey() { return (uint8_t *)(this + 1); }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Node256 : Node {
|
struct Node256 : Node {
|
||||||
@@ -237,6 +241,7 @@ struct Node256 : Node {
|
|||||||
children[i].child = nullptr;
|
children[i].child = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
uint8_t *partialKey() { return (uint8_t *)(this + 1); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class NodeT> NodeT *newNode(int partialKeyCapacity) {
|
template <class NodeT> NodeT *newNode(int partialKeyCapacity) {
|
||||||
@@ -250,15 +255,15 @@ template <class NodeT> NodeT *newNode(int partialKeyCapacity) {
|
|||||||
uint8_t *Node::partialKey() {
|
uint8_t *Node::partialKey() {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Type::Node0:
|
case Type::Node0:
|
||||||
return (uint8_t *)((Node0 *)this + 1);
|
return ((Node0 *)this)->partialKey();
|
||||||
case Type::Node4:
|
case Type::Node4:
|
||||||
return (uint8_t *)((Node4 *)this + 1);
|
return ((Node4 *)this)->partialKey();
|
||||||
case Type::Node16:
|
case Type::Node16:
|
||||||
return (uint8_t *)((Node16 *)this + 1);
|
return ((Node16 *)this)->partialKey();
|
||||||
case Type::Node48:
|
case Type::Node48:
|
||||||
return (uint8_t *)((Node48 *)this + 1);
|
return ((Node48 *)this)->partialKey();
|
||||||
case Type::Node256:
|
case Type::Node256:
|
||||||
return (uint8_t *)((Node256 *)this + 1);
|
return ((Node256 *)this)->partialKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user