From 8556caf3603eb2719830f37bc9386fcec2f21a0b Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Fri, 15 Mar 2024 16:57:16 -0700 Subject: [PATCH] Cachegrind says memset uses fewer instructions here --- ConflictSet.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 5358115..6da19a9 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -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) {