HomePhabricator

Avoid double copy when emplacing into DisconnectedBlockTransactons::txInfo

Description

Avoid double copy when emplacing into DisconnectedBlockTransactons::txInfo

Summary:

MR !1128 introduced this code but on second reading I realized the
double-copy from this MR can be remove by using `try_emplace` and also by actually giving the `TxInfo` type a real constructor.

This commit is just a minor code quality commit to reduce the creation of a temporary.  In most cases the optimizer will elide this temporary anyway, but for debug builds it may not, and also it's of higher code quality to just avoid creating it.

Port of bchn#1191.
Depends on D13171.

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Subscribers: PiRK

Differential Revision: https://reviews.bitcoinabc.org/D13178

Details

Provenance
CCulianuAuthored on Apr 24 2021, 02:19
FabienCommitted on Feb 28 2023, 08:01
FabienPushed on Feb 28 2023, 08:01
Reviewer
Restricted Project
Differential Revision
D13178: Avoid double copy when emplacing into DisconnectedBlockTransactons::txInfo
Parents
rABC4d6e97182f60: mempool: Slight performance nit when erasing from setEntries
Branches
Unknown
Tags
Unknown