Make objects in range declarations immutable by default. Avoid unnecessary copying of objects in range declarations.#13249
Conversation
|
How about also including the range-for changes from #12158? |
|
@Empact I think it better to do (a subset of) the #12158 changes in follow-up PRs to keep this PR as mechanical and easy-to-review as possible. Basically what @laanwj suggested in #12158 (comment) :-) This PR should hopefully be trivial to review :-) |
|
Yeah, I like it as-is, just suggesting since the Anyway, you have my Tested ACK 3299ed7. |
|
Rebased! |
|
utACK 0143466 |
|
utACK 0143466 |
promag
left a comment
There was a problem hiding this comment.
I've only made some comments where I think the iterated type can be const &. Can you review the whole change if you agree with such change?
src/miner.cpp
Outdated
src/net.cpp
Outdated
src/net_processing.cpp
Outdated
src/net_processing.cpp
Outdated
3e16523 to
9a4655f
Compare
|
@promag Thanks for reviewing! Feedback addressed. Please re-review :-) |
src/policy/rbf.cpp
Outdated
There was a problem hiding this comment.
nit: Could be a reference too for consistency with src/miner.cpp.
src/qt/bitcoin.cpp
Outdated
There was a problem hiding this comment.
I'm not sure I understand what whitespace change you're suggesting? :-)
There was a problem hiding this comment.
Just that the developer-notes prefer WalletModel*. Fine to ignore.
src/rpc/blockchain.cpp
Outdated
src/txmempool.cpp
Outdated
src/wallet/wallet.cpp
Outdated
src/wallet/walletdb.cpp
Outdated
|
All nits, just calling out handling where inconsistent. |
|
utACK 9a4655fd15e632d95651e4681936f8ea13457ae1 These changes should be obviously safe. Adding |
9a4655f to
2b132fe
Compare
ea2cd74 to
6a980ed
Compare
|
Rebased! :-) |
promag
left a comment
There was a problem hiding this comment.
Comments regarding auto usage.
src/wallet/wallet.cpp
Outdated
There was a problem hiding this comment.
Could use const COutput& coin?
src/validation.cpp
Outdated
There was a problem hiding this comment.
Most common usage when iterating mapBlockIndex is
for (const std::pair<const uint256, CBlockIndex*>& item : mapBlockIndex)And there is also the above:
for (const BlockMap::value_type& entry : mapBlockIndex)(I prefer the 1st).
src/wallet/wallet.cpp
Outdated
There was a problem hiding this comment.
Could use const CTxIn& input (most common usage).
279caa6 to
ddd0045
Compare
|
@promag Thanks for reviewing. Feedback addressed. Please re-review :-) |
…ssary copying of objects in range declarations.
ddd0045 to
f34c8c4
Compare
|
Rebased! Please re-review :-) |
|
utACK f34c8c4 |
…. Avoid unnecessary copying of objects in range declarations. f34c8c4 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
…ssary copying of objects in range declarations. Summary: Make objects in range declarations immutable by default. Backport of Bitcoin Core PR13249 bitcoin/bitcoin#13249 (D4191 done again) Test Plan: ``` make check-all ``` Reviewers: Fabien, #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D4221
…default. Avoid unnecessary copying of objects in range declarations. f34c8c4 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
…default. Avoid unnecessary copying of objects in range declarations. f34c8c4 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
Make objects in range declarations immutable by default.
Rationale: