Move Node::type to beginning of Node
All checks were successful
Tests / Release [gcc] total: 704, passed: 704
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|1|1|0|0|:-1:
Reference build: <a href="https://jenkins.weaselab.dev/job/weaselab/job/conflict-set/job/main/64//gcc">weaselab » conflict-set » main #64</a>
Tests / Release [gcc,aarch64] total: 703, passed: 703
Tests / Coverage total: 702, passed: 702
weaselab/conflict-set/pipeline/head This commit looks good
All checks were successful
Tests / Release [gcc] total: 704, passed: 704
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|1|1|0|0|:-1:
Reference build: <a href="https://jenkins.weaselab.dev/job/weaselab/job/conflict-set/job/main/64//gcc">weaselab » conflict-set » main #64</a>
Tests / Release [gcc,aarch64] total: 703, passed: 703
Tests / Coverage total: 702, passed: 702
weaselab/conflict-set/pipeline/head This commit looks good
This prepares us to have a variable size leaf type
This commit is contained in:
@@ -231,18 +231,18 @@ enum class Type : int8_t {
|
||||
constexpr static int kPartialKeyMaxLenEntryPresent = 24;
|
||||
|
||||
struct Node {
|
||||
Type type = Type::Invalid;
|
||||
|
||||
/* begin section that's copied to the next node */
|
||||
bool entryPresent = false;
|
||||
uint8_t parentsIndex = 0;
|
||||
int8_t partialKeyLen = 0;
|
||||
int32_t numChildren = 0;
|
||||
Node *parent = nullptr;
|
||||
uint8_t partialKey[kPartialKeyMaxLenEntryPresent];
|
||||
// If not entryPresent, then the partial key might spill over into entry
|
||||
Entry entry;
|
||||
int32_t numChildren = 0;
|
||||
bool entryPresent = false;
|
||||
uint8_t parentsIndex = 0;
|
||||
int8_t partialKeyLen = 0;
|
||||
/* end section that's copied to the next node */
|
||||
|
||||
Type type = Type::Invalid;
|
||||
};
|
||||
|
||||
static_assert(offsetof(Node, entry) ==
|
||||
@@ -571,7 +571,9 @@ Node *&getOrCreateChild(Node *&self, uint8_t index,
|
||||
if (self->numChildren == 16) {
|
||||
auto *self16 = static_cast<Node16 *>(self);
|
||||
auto *newSelf = allocators->node48.allocate();
|
||||
memcpy((void *)newSelf, self, offsetof(Node, type));
|
||||
memcpy((char *)newSelf + sizeof(Node::type),
|
||||
(char *)self + sizeof(Node::type),
|
||||
sizeof(Node) - sizeof(Node::type));
|
||||
newSelf->nextFree = 16;
|
||||
int i = 0;
|
||||
for (auto x : self16->index) {
|
||||
@@ -610,7 +612,9 @@ Node *&getOrCreateChild(Node *&self, uint8_t index,
|
||||
if (self->numChildren == 48) {
|
||||
auto *self48 = static_cast<Node48 *>(self);
|
||||
auto *newSelf = allocators->node256.allocate();
|
||||
memcpy((void *)newSelf, self, offsetof(Node, type));
|
||||
memcpy((char *)newSelf + sizeof(Node::type),
|
||||
(char *)self + sizeof(Node::type),
|
||||
sizeof(Node) - sizeof(Node::type));
|
||||
newSelf->bitSet = self48->bitSet;
|
||||
newSelf->bitSet.forEachInRange(
|
||||
[&](int i) {
|
||||
@@ -1542,7 +1546,9 @@ template <bool kBegin>
|
||||
|
||||
*self = allocators->node1.allocate();
|
||||
|
||||
memcpy((void *)*self, old, offsetof(Node, type));
|
||||
memcpy((char *)*self + sizeof(Node::type),
|
||||
(char *)old + sizeof(Node::type),
|
||||
sizeof(Node) - sizeof(Node::type));
|
||||
(*self)->partialKeyLen = partialKeyIndex;
|
||||
(*self)->entryPresent = false;
|
||||
(*self)->numChildren = 0;
|
||||
|
Reference in New Issue
Block a user