Save some instructions in getOrCreateChild
All checks were successful
Tests / Release [gcc] total: 471, passed: 471
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|0|0|0|0|:clap:
Reference build: <a href="https://jenkins.weaselab.dev/job/weaselab/job/conflict-set/job/main/35//gcc">weaselab » conflict-set » main #35</a>
Tests / Coverage total: 469, passed: 469
weaselab/conflict-set/pipeline/head This commit looks good
All checks were successful
Tests / Release [gcc] total: 471, passed: 471
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|0|0|0|0|:clap:
Reference build: <a href="https://jenkins.weaselab.dev/job/weaselab/job/conflict-set/job/main/35//gcc">weaselab » conflict-set » main #35</a>
Tests / Coverage total: 469, passed: 469
weaselab/conflict-set/pipeline/head This commit looks good
This commit is contained in:
@@ -384,12 +384,9 @@ Node *&getOrCreateChild(Node *&self, uint8_t index,
|
||||
NodeAllocators *allocators) {
|
||||
if (self->type == Type::Node4) {
|
||||
auto *self4 = static_cast<Node4 *>(self);
|
||||
{
|
||||
int i = getNodeIndex((Node16 *)self4, index);
|
||||
if (i >= 0) {
|
||||
if (int i = getNodeIndex((Node16 *)self4, index); i >= 0) {
|
||||
return self4->children[i];
|
||||
}
|
||||
}
|
||||
if (self->numChildren == 4) {
|
||||
auto *newSelf = allocators->node16.allocate();
|
||||
memcpy((void *)newSelf, self, offsetof(Node, type));
|
||||
@@ -419,12 +416,10 @@ Node *&getOrCreateChild(Node *&self, uint8_t index,
|
||||
} else if (self->type == Type::Node16) {
|
||||
insert16:
|
||||
auto *self16 = static_cast<Node16 *>(self);
|
||||
{
|
||||
int i = getNodeIndex(self16, index);
|
||||
if (i >= 0) {
|
||||
|
||||
if (int i = getNodeIndex(self16, index); i >= 0) {
|
||||
return self16->children[i];
|
||||
}
|
||||
}
|
||||
if (self->numChildren == 16) {
|
||||
auto *newSelf = allocators->node48.allocate();
|
||||
memcpy((void *)newSelf, self, offsetof(Node, type));
|
||||
@@ -461,8 +456,10 @@ Node *&getOrCreateChild(Node *&self, uint8_t index,
|
||||
} else if (self->type == Type::Node48) {
|
||||
insert48:
|
||||
auto *self48 = static_cast<Node48 *>(self);
|
||||
if (self48->bitSet.test(index)) {
|
||||
return self48->children[self48->index[index]];
|
||||
if (int c = self48->index[index];
|
||||
|
||||
c >= 0) {
|
||||
return self48->children[c];
|
||||
}
|
||||
if (self->numChildren == 48) {
|
||||
auto *newSelf = allocators->node256.allocate();
|
||||
@@ -488,11 +485,13 @@ Node *&getOrCreateChild(Node *&self, uint8_t index,
|
||||
} else {
|
||||
insert256:
|
||||
auto *self256 = static_cast<Node256 *>(self);
|
||||
if (!self256->children[index]) {
|
||||
++self->numChildren;
|
||||
auto *&result = self256->children[index];
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
++self->numChildren;
|
||||
self256->bitSet.set(index);
|
||||
return self256->children[index];
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user