mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-09 08:43:04 +01:00
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