net: reference instead of copy in BlockConnected range loop #18054

pull jonatack wants to merge 1 commits into bitcoin:master from jonatack:block-connected-ref-instead-of-copy changing 1 files +1 −1
  1. jonatack commented at 9:30 AM on February 2, 2020: member

    Reference elements in range for loop instead of copying them and fix Clang -Wrange-loop-analysis warning introduced in a029e18

    net_processing.cpp:1185:25: warning: loop variable 'ptx' of
    type 'const std::shared_ptr<const CTransaction>' creates a copy from
    type 'const std::shared_ptr<const CTransaction>' [-Wrange-loop-analysis]
            for (const auto ptx : pblock->vtx) {
                            ^
    net_processing.cpp:1185:14: note: use reference type
    'const std::shared_ptr<const CTransaction> &' to prevent copying
            for (const auto ptx : pblock->vtx) {
                 ^~~~~~~~~~~~~~~~
    1 warning generated.
    
  2. net: reference instead of copy in BlockConnected range loop
    to fix -Wrange-loop-analysis warning introduced in a029e18
    9a299a59cc
  3. fanquake added the label P2P on Feb 2, 2020
  4. MarcoFalke commented at 9:53 AM on February 2, 2020: member

    ACK 9a299a59cc8a9ab516e047356c5bc0e93774b557

  5. promag commented at 1:45 PM on February 2, 2020: member

    ACK 9a299a59cc8a9ab516e047356c5bc0e93774b557.

  6. elichai approved
  7. elichai commented at 3:16 PM on February 2, 2020: contributor

    Compiled with clang 9.0.1, got the same warning which this fix (this is a shared_ptr so copying is somewhat more expensive than a primitive (bumps the ref counter)) ACK 9a299a59cc8a9ab516e047356c5bc0e93774b557

  8. emilengler commented at 3:45 PM on February 2, 2020: contributor

    ACK 9a299a5.

  9. fanquake referenced this in commit 365c83e6a8 on Feb 3, 2020
  10. fanquake merged this on Feb 3, 2020
  11. fanquake closed this on Feb 3, 2020

  12. jonatack deleted the branch on Feb 3, 2020
  13. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-14 21:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me