Merge #13249: Make objects in range declarations immutable by default. Avoid unnecessary copying of objects in range declarations.
f34c8c466a Make objects in range declarations immutable by default. Avoid unnecessary copying of objects in range declarations. (practicalswift)
Pull request description:
Make objects in range declarations immutable by default.
Rationale:
* Immutable objects are easier to reason about.
* Prevents accidental or hard-to-notice change of value.
Tree-SHA512: cad69d35f0cf8a938b848e65dd537c621d96fe3369be306b65ef0cd1baf6cc0a9f28bc230e1e383d810c555a6743d08cb6b2b0bd51856d4611f537a12e5abb8b
This commit is contained in:
+3
-3
@@ -193,7 +193,7 @@ bool CTxMemPool::CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, setEntr
|
||||
}
|
||||
|
||||
const setEntries & setMemPoolParents = GetMemPoolParents(stageit);
|
||||
for (const txiter &phash : setMemPoolParents) {
|
||||
for (txiter phash : setMemPoolParents) {
|
||||
// If this is a new ancestor, add it.
|
||||
if (setAncestors.count(phash) == 0) {
|
||||
parentHashes.insert(phash);
|
||||
@@ -454,7 +454,7 @@ void CTxMemPool::CalculateDescendants(txiter entryit, setEntries& setDescendants
|
||||
stage.erase(it);
|
||||
|
||||
const setEntries &setChildren = GetMemPoolChildren(it);
|
||||
for (const txiter &childiter : setChildren) {
|
||||
for (txiter childiter : setChildren) {
|
||||
if (!setDescendants.count(childiter)) {
|
||||
stage.insert(childiter);
|
||||
}
|
||||
@@ -899,7 +899,7 @@ size_t CTxMemPool::DynamicMemoryUsage() const {
|
||||
void CTxMemPool::RemoveStaged(setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason) {
|
||||
AssertLockHeld(cs);
|
||||
UpdateForRemoveFromMempool(stage, updateDescendants);
|
||||
for (const txiter& it : stage) {
|
||||
for (txiter it : stage) {
|
||||
removeUnchecked(it, reason);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user