mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-23 20:35:02 +02:00
Merge bitcoin/bitcoin#31650: refactor: Avoid copies by using const references or by move-construction
fa64d8424brefactor: Enforce readability-avoid-const-params-in-decls (MarcoFalke)faf0c2d942refactor: Avoid copies by using const references or by move-construction (MarcoFalke) Pull request description: Top level `const` in declarations is problematic for many reasons: * It is often a typo, where one wanted to denote a const reference. For example `bool PSBTInputSignedAndVerified(const PartiallySignedTransaction psbt, ...` is missing the `&`. This will create a redundant copy of the value. * In constructors it prevents move construction. * It can incorrectly imply some data is const, like in an imaginary example `std::span<int> Shuffle(const std::span<int>);`, where the `int`s are *not* const. * The compiler ignores the `const` from the declaration in the implementation. * It isn't used consistently anyway, not even on the same line. Fix some issues by: * Using a const reference to avoid a copy, where read-only of the value is intended. This is only done for values that may be expensive to copy. * Using move-construction to avoid a copy * Applying `readability-avoid-const-params-in-decls` via clang-tidy ACKs for top commit: l0rinc: diff reACKfa64d8424bhebasto: ACKfa64d8424b, I have reviewed the code and it looks OK. sedited: ACKfa64d8424bTree-SHA512: 293c000b4ebf8fdcc75259eb0283a2e4e7892c73facfb5c3182464d6cb6a868b7f4a6682d664426bf2edecd665cf839d790bef0bae43a8c3bf1ddfdd3d068d38
This commit is contained in:
@@ -28,7 +28,7 @@ struct MinerTestingSetup : public RegTestingSetup {
|
||||
std::shared_ptr<const CBlock> GoodBlock(const uint256& prev_hash);
|
||||
std::shared_ptr<const CBlock> BadBlock(const uint256& prev_hash);
|
||||
std::shared_ptr<CBlock> FinalizeBlock(std::shared_ptr<CBlock> pblock);
|
||||
void BuildChain(const uint256& root, int height, const unsigned int invalid_rate, const unsigned int branch_rate, const unsigned int max_size, std::vector<std::shared_ptr<const CBlock>>& blocks);
|
||||
void BuildChain(const uint256& root, int height, unsigned int invalid_rate, unsigned int branch_rate, unsigned int max_size, std::vector<std::shared_ptr<const CBlock>>& blocks);
|
||||
};
|
||||
} // namespace validation_block_tests
|
||||
|
||||
|
||||
Reference in New Issue
Block a user