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:
@@ -736,7 +736,7 @@ static void CheckAddCoinBase(CAmount base_value, CAmount cache_value, CAmount mo
|
||||
template <typename... Args>
|
||||
static void CheckAddCoin(Args&&... args)
|
||||
{
|
||||
for (CAmount base_value : {ABSENT, PRUNED, VALUE1})
|
||||
for (const CAmount base_value : {ABSENT, PRUNED, VALUE1})
|
||||
CheckAddCoinBase(base_value, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
@@ -848,10 +848,10 @@ BOOST_AUTO_TEST_CASE(ccoins_write)
|
||||
// they would be too repetitive (the parent cache is never updated in these
|
||||
// cases). The loop below covers these cases and makes sure the parent cache
|
||||
// is always left unchanged.
|
||||
for (CAmount parent_value : {ABSENT, PRUNED, VALUE1})
|
||||
for (CAmount child_value : {ABSENT, PRUNED, VALUE2})
|
||||
for (char parent_flags : parent_value == ABSENT ? ABSENT_FLAGS : FLAGS)
|
||||
for (char child_flags : child_value == ABSENT ? ABSENT_FLAGS : CLEAN_FLAGS)
|
||||
for (const CAmount parent_value : {ABSENT, PRUNED, VALUE1})
|
||||
for (const CAmount child_value : {ABSENT, PRUNED, VALUE2})
|
||||
for (const char parent_flags : parent_value == ABSENT ? ABSENT_FLAGS : FLAGS)
|
||||
for (const char child_flags : child_value == ABSENT ? ABSENT_FLAGS : CLEAN_FLAGS)
|
||||
CheckWriteCoins(parent_value, child_value, parent_value, parent_flags, child_flags, parent_flags);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user