Skip to content

Commit 365c83e

Browse files
committed
Merge #18054: net: reference instead of copy in BlockConnected range loop
9a299a5 net: reference instead of copy in BlockConnected range loop (Jon Atack) Pull request description: 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. ``` ACKs for top commit: Empact: ACK bitcoin/bitcoin@9a299a5 MarcoFalke: ACK 9a299a5 promag: ACK 9a299a5. elichai: ACK 9a299a5 emilengler: ACK 9a299a5. Tree-SHA512: 9284d1b00684877505454a05071212758c8cea083534e2eec09bfc8a9c3059eea811d2008f6a5a678539444f0d5b3134db1bd23da6514b3d3a1440634c8b53be
2 parents 6d0e532 + 9a299a5 commit 365c83e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ void PeerLogicValidation::BlockConnected(const std::shared_ptr<const CBlock>& pb
11821182
}
11831183
{
11841184
LOCK(g_cs_recent_confirmed_transactions);
1185-
for (const auto ptx : pblock->vtx) {
1185+
for (const auto& ptx : pblock->vtx) {
11861186
g_recent_confirmed_transactions->insert(ptx->GetHash());
11871187
}
11881188
}

0 commit comments

Comments
 (0)