Remove small memmoves in erase
This commit is contained in:
@@ -1511,36 +1511,24 @@ Node *erase(Node *self, WriteContext *tls, ConflictSet::Impl *impl,
|
||||
auto *parent3 = static_cast<Node3 *>(parent);
|
||||
int nodeIndex = getNodeIndex(parent3, parentsIndex);
|
||||
assert(nodeIndex >= 0);
|
||||
memmove(parent3->index + nodeIndex, parent3->index + nodeIndex + 1,
|
||||
sizeof(parent3->index[0]) *
|
||||
(parent->numChildren - (nodeIndex + 1)));
|
||||
memmove(parent3->children + nodeIndex, parent3->children + nodeIndex + 1,
|
||||
sizeof(parent3->children[0]) * // NOLINT
|
||||
(parent->numChildren - (nodeIndex + 1)));
|
||||
memmove(parent3->childMaxVersion + nodeIndex,
|
||||
parent3->childMaxVersion + nodeIndex + 1,
|
||||
sizeof(parent3->childMaxVersion[0]) *
|
||||
(parent->numChildren - (nodeIndex + 1)));
|
||||
|
||||
--parent->numChildren;
|
||||
for (int i = nodeIndex; i < parent->numChildren; ++i) {
|
||||
parent3->index[i] = parent3->index[i + 1];
|
||||
parent3->children[i] = parent3->children[i + 1];
|
||||
parent3->childMaxVersion[i] = parent3->childMaxVersion[i + 1];
|
||||
}
|
||||
assert(parent->numChildren > 0 || parent->entryPresent);
|
||||
} break;
|
||||
case Type_Node16: {
|
||||
auto *parent16 = static_cast<Node16 *>(parent);
|
||||
int nodeIndex = getNodeIndex(parent16, parentsIndex);
|
||||
assert(nodeIndex >= 0);
|
||||
memmove(parent16->index + nodeIndex, parent16->index + nodeIndex + 1,
|
||||
sizeof(parent16->index[0]) *
|
||||
(parent->numChildren - (nodeIndex + 1)));
|
||||
memmove(parent16->children + nodeIndex, parent16->children + nodeIndex + 1,
|
||||
sizeof(parent16->children[0]) * // NOLINT
|
||||
(parent->numChildren - (nodeIndex + 1)));
|
||||
memmove(parent16->childMaxVersion + nodeIndex,
|
||||
parent16->childMaxVersion + nodeIndex + 1,
|
||||
sizeof(parent16->childMaxVersion[0]) *
|
||||
(parent->numChildren - (nodeIndex + 1)));
|
||||
|
||||
--parent->numChildren;
|
||||
for (int i = nodeIndex; i < parent->numChildren; ++i) {
|
||||
parent16->index[i] = parent16->index[i + 1];
|
||||
parent16->children[i] = parent16->children[i + 1];
|
||||
parent16->childMaxVersion[i] = parent16->childMaxVersion[i + 1];
|
||||
}
|
||||
|
||||
// By kMinChildrenNode16
|
||||
assert(parent->numChildren > 0);
|
||||
|
Reference in New Issue
Block a user