mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Prevent unnecessary shared_ptr copies by accepting a value in SHAMapInnerNode::setChild (#4266)
* Do a move instead of a copy in `SHAMapInnerNode::setChild` * Create the value directly in the call
This commit is contained in:
committed by
Richard Holland
parent
c912b939d6
commit
d46664df0f
@@ -284,7 +284,7 @@ SHAMapInnerNode::getString(const SHAMapNodeID& id) const
|
||||
|
||||
// We are modifying an inner node
|
||||
void
|
||||
SHAMapInnerNode::setChild(int m, std::shared_ptr<SHAMapTreeNode> const& child)
|
||||
SHAMapInnerNode::setChild(int m, std::shared_ptr<SHAMapTreeNode> child)
|
||||
{
|
||||
assert((m >= 0) && (m < branchFactor));
|
||||
assert(cowid_ != 0);
|
||||
@@ -310,7 +310,7 @@ SHAMapInnerNode::setChild(int m, std::shared_ptr<SHAMapTreeNode> const& child)
|
||||
auto const childIndex = *getChildIndex(m);
|
||||
auto [_, hashes, children] = hashesAndChildren_.getHashesAndChildren();
|
||||
hashes[childIndex].zero();
|
||||
children[childIndex] = child;
|
||||
children[childIndex] = std::move(child);
|
||||
}
|
||||
|
||||
hash_.zero();
|
||||
|
||||
Reference in New Issue
Block a user