Only skip free list from maybeDecreaseCapacity
All checks were successful
Tests / Release [gcc] total: 932, passed: 932
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|0|0|0|0|:clap:
Tests / Release [gcc,aarch64] total: 931, passed: 931
Tests / Coverage total: 930, passed: 930
weaselab/conflict-set/pipeline/head This commit looks good
All checks were successful
Tests / Release [gcc] total: 932, passed: 932
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|0|0|0|0|:clap:
Tests / Release [gcc,aarch64] total: 931, passed: 931
Tests / Coverage total: 930, passed: 930
weaselab/conflict-set/pipeline/head This commit looks good
This commit is contained in:
@@ -744,7 +744,8 @@ Node *nextLogical(Node *node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Invalidates `self`, replacing it with a node of at least capacity.
|
// Invalidates `self`, replacing it with a node of at least capacity.
|
||||||
// Does not return nodes to freelists.
|
// Does not return nodes to freelists when kUseFreeList is false.
|
||||||
|
template <bool kUseFreeList>
|
||||||
void makeCapacityAtLeast(Node *&self, int capacity, NodeAllocators *allocators,
|
void makeCapacityAtLeast(Node *&self, int capacity, NodeAllocators *allocators,
|
||||||
ConflictSet::Impl *impl) {
|
ConflictSet::Impl *impl) {
|
||||||
switch (self->type) {
|
switch (self->type) {
|
||||||
@@ -755,7 +756,11 @@ void makeCapacityAtLeast(Node *&self, int capacity, NodeAllocators *allocators,
|
|||||||
kNodeCopySize);
|
kNodeCopySize);
|
||||||
memcpy(newSelf->partialKey(), self0->partialKey(), self->partialKeyLen);
|
memcpy(newSelf->partialKey(), self0->partialKey(), self->partialKeyLen);
|
||||||
getInTree(self, impl) = newSelf;
|
getInTree(self, impl) = newSelf;
|
||||||
|
if constexpr (kUseFreeList) {
|
||||||
|
allocators->node0.release(self0);
|
||||||
|
} else {
|
||||||
free(self0);
|
free(self0);
|
||||||
|
}
|
||||||
self = newSelf;
|
self = newSelf;
|
||||||
} break;
|
} break;
|
||||||
case Type::Node4: {
|
case Type::Node4: {
|
||||||
@@ -771,7 +776,11 @@ void makeCapacityAtLeast(Node *&self, int capacity, NodeAllocators *allocators,
|
|||||||
}
|
}
|
||||||
getInTree(self, impl) = newSelf;
|
getInTree(self, impl) = newSelf;
|
||||||
setChildrenParents(newSelf);
|
setChildrenParents(newSelf);
|
||||||
|
if constexpr (kUseFreeList) {
|
||||||
|
allocators->node4.release(self4);
|
||||||
|
} else {
|
||||||
free(self4);
|
free(self4);
|
||||||
|
}
|
||||||
self = newSelf;
|
self = newSelf;
|
||||||
} break;
|
} break;
|
||||||
case Type::Node16: {
|
case Type::Node16: {
|
||||||
@@ -787,7 +796,11 @@ void makeCapacityAtLeast(Node *&self, int capacity, NodeAllocators *allocators,
|
|||||||
}
|
}
|
||||||
getInTree(self, impl) = newSelf;
|
getInTree(self, impl) = newSelf;
|
||||||
setChildrenParents(newSelf);
|
setChildrenParents(newSelf);
|
||||||
|
if constexpr (kUseFreeList) {
|
||||||
|
allocators->node16.release(self16);
|
||||||
|
} else {
|
||||||
free(self16);
|
free(self16);
|
||||||
|
}
|
||||||
self = newSelf;
|
self = newSelf;
|
||||||
} break;
|
} break;
|
||||||
case Type::Node48: {
|
case Type::Node48: {
|
||||||
@@ -807,7 +820,11 @@ void makeCapacityAtLeast(Node *&self, int capacity, NodeAllocators *allocators,
|
|||||||
0, 256);
|
0, 256);
|
||||||
getInTree(self, impl) = newSelf;
|
getInTree(self, impl) = newSelf;
|
||||||
setChildrenParents(newSelf);
|
setChildrenParents(newSelf);
|
||||||
|
if constexpr (kUseFreeList) {
|
||||||
|
allocators->node48.release(self48);
|
||||||
|
} else {
|
||||||
free(self48);
|
free(self48);
|
||||||
|
}
|
||||||
self = newSelf;
|
self = newSelf;
|
||||||
} break;
|
} break;
|
||||||
case Type::Node256: {
|
case Type::Node256: {
|
||||||
@@ -821,7 +838,11 @@ void makeCapacityAtLeast(Node *&self, int capacity, NodeAllocators *allocators,
|
|||||||
[&](int c) { newSelf->children[c] = self256->children[c]; }, 0, 256);
|
[&](int c) { newSelf->children[c] = self256->children[c]; }, 0, 256);
|
||||||
getInTree(self, impl) = newSelf;
|
getInTree(self, impl) = newSelf;
|
||||||
setChildrenParents(newSelf);
|
setChildrenParents(newSelf);
|
||||||
|
if constexpr (kUseFreeList) {
|
||||||
|
allocators->node256.release(self256);
|
||||||
|
} else {
|
||||||
free(self256);
|
free(self256);
|
||||||
|
}
|
||||||
self = newSelf;
|
self = newSelf;
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
@@ -837,7 +858,8 @@ void maybeDecreaseCapacity(Node *&self, NodeAllocators *allocators,
|
|||||||
if (self->partialKeyCapacity <= maxCapacity) {
|
if (self->partialKeyCapacity <= maxCapacity) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
makeCapacityAtLeast(self, maxCapacity, allocators, impl);
|
makeCapacityAtLeast</*kUseFreeList*/ false>(self, maxCapacity, allocators,
|
||||||
|
impl);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO fuse into erase child so we don't need to repeat branches on type
|
// TODO fuse into erase child so we don't need to repeat branches on type
|
||||||
@@ -868,7 +890,8 @@ void maybeDownsize(Node *self, NodeAllocators *allocators,
|
|||||||
|
|
||||||
if (minCapacity > child->partialKeyCapacity) {
|
if (minCapacity > child->partialKeyCapacity) {
|
||||||
const bool update = child == dontInvalidate;
|
const bool update = child == dontInvalidate;
|
||||||
makeCapacityAtLeast(child, minCapacity, allocators, impl);
|
makeCapacityAtLeast</*kUseFreeList*/ true>(child, minCapacity,
|
||||||
|
allocators, impl);
|
||||||
if (update) {
|
if (update) {
|
||||||
dontInvalidate = child;
|
dontInvalidate = child;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user