Cachegrind says memset uses fewer instructions here

This commit is contained in:
2024-03-15 16:57:16 -07:00
parent 9d13ca84f5
commit 8556caf360

View File

@@ -447,9 +447,7 @@ inline void Node48::copyChildrenAndKeyFrom(const Node256 &other) {
inline void Node256::copyChildrenAndKeyFrom(const Node48 &other) {
memcpy((char *)this + kNodeCopyBegin, (char *)&other + kNodeCopyBegin,
kNodeCopySize);
for (int i = 0; i < 256; ++i) {
children[i].child = nullptr;
}
memset(children, 0, sizeof(children));
bitSet = other.bitSet;
bitSet.forEachInRange(
[&](int c) {
@@ -464,9 +462,7 @@ inline void Node256::copyChildrenAndKeyFrom(const Node48 &other) {
inline void Node256::copyChildrenAndKeyFrom(const Node256 &other) {
memcpy((char *)this + kNodeCopyBegin, (char *)&other + kNodeCopyBegin,
kNodeCopySize);
for (int i = 0; i < 256; ++i) {
children[i].child = nullptr;
}
memset(children, 0, sizeof(children));
bitSet = other.bitSet;
bitSet.forEachInRange(
[&](int c) {