mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-24 22:45:41 +01:00
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:
@@ -421,7 +421,7 @@ bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints* lp, bool
|
||||
// lock on a mempool input, so we can use the return value of
|
||||
// CheckSequenceLocks to indicate the LockPoints validity
|
||||
int maxInputHeight = 0;
|
||||
for (int height : prevheights) {
|
||||
for (const int height : prevheights) {
|
||||
// Can ignore mempool inputs since we'll fail if they had non-zero locks
|
||||
if (height != tip->nHeight+1) {
|
||||
maxInputHeight = std::max(maxInputHeight, height);
|
||||
@@ -4291,7 +4291,7 @@ void UnloadBlockIndex()
|
||||
warningcache[b].clear();
|
||||
}
|
||||
|
||||
for (BlockMap::value_type& entry : mapBlockIndex) {
|
||||
for (const BlockMap::value_type& entry : mapBlockIndex) {
|
||||
delete entry.second;
|
||||
}
|
||||
mapBlockIndex.clear();
|
||||
@@ -4492,7 +4492,7 @@ void CChainState::CheckBlockIndex(const Consensus::Params& consensusParams)
|
||||
|
||||
// Build forward-pointing map of the entire block tree.
|
||||
std::multimap<CBlockIndex*,CBlockIndex*> forward;
|
||||
for (auto& entry : mapBlockIndex) {
|
||||
for (const std::pair<const uint256, CBlockIndex*>& entry : mapBlockIndex) {
|
||||
forward.insert(std::make_pair(entry.second->pprev, entry.second));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user