Skip to content

Commit a26a974

Browse files
committed
perf: std::move a shared_ptr with islock in ProcessMessage
1 parent 3c26523 commit a26a974

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/instantsend/instantsend.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ CInstantSendManager::~CInstantSendManager() = default;
6666
bool ShouldReportISLockTiming() { return g_stats_client->active() || LogAcceptDebug(BCLog::INSTANTSEND); }
6767

6868
void CInstantSendManager::EnqueueInstantSendLock(NodeId from, const uint256& hash,
69-
const std::shared_ptr<instantsend::InstantSendLock>& islock)
69+
std::shared_ptr<instantsend::InstantSendLock> islock)
7070
{
7171
if (ShouldReportISLockTiming()) {
7272
auto time_diff = [&]() -> int64_t {
@@ -86,7 +86,7 @@ void CInstantSendManager::EnqueueInstantSendLock(NodeId from, const uint256& has
8686
}
8787

8888
LOCK(cs_pendingLocks);
89-
pendingInstantSendLocks.emplace(hash, instantsend::PendingISLockFromPeer{from, islock});
89+
pendingInstantSendLocks.emplace(hash, instantsend::PendingISLockFromPeer{from, std::move(islock)});
9090
}
9191

9292
instantsend::PendingState CInstantSendManager::FetchPendingLocks()

src/instantsend/instantsend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class CInstantSendManager final : public instantsend::InstantSendSignerParent
135135
/* Helpers for communications between CInstantSendManager & NetInstantSend */
136136
// This helper returns up to 32 pending locks and remove them from queue of pending
137137
[[nodiscard]] instantsend::PendingState FetchPendingLocks() EXCLUSIVE_LOCKS_REQUIRED(!cs_pendingLocks);
138-
void EnqueueInstantSendLock(NodeId from, const uint256& hash, const std::shared_ptr<instantsend::InstantSendLock>& islock)
138+
void EnqueueInstantSendLock(NodeId from, const uint256& hash, std::shared_ptr<instantsend::InstantSendLock> islock)
139139
EXCLUSIVE_LOCKS_REQUIRED(!cs_pendingLocks);
140140
[[nodiscard]] std::vector<CTransactionRef> PrepareTxToRetry()
141141
EXCLUSIVE_LOCKS_REQUIRED(!cs_nonLocked, !cs_pendingRetry);

src/instantsend/net_instantsend.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void NetInstantSend::ProcessMessage(CNode& pfrom, const std::string& msg_type, C
2222

2323
if (!m_is_manager.IsInstantSendEnabled()) return;
2424

25-
const auto islock = std::make_shared<instantsend::InstantSendLock>();
25+
auto islock = std::make_shared<instantsend::InstantSendLock>();
2626
vRecv >> *islock;
2727

2828
uint256 hash = ::SerializeHash(*islock);
@@ -60,7 +60,7 @@ void NetInstantSend::ProcessMessage(CNode& pfrom, const std::string& msg_type, C
6060
LogPrint(BCLog::INSTANTSEND, "NetInstantSend -- ISDLOCK txid=%s, islock=%s: received islock, peer=%d\n",
6161
islock->txid.ToString(), hash.ToString(), pfrom.GetId());
6262

63-
m_is_manager.EnqueueInstantSendLock(pfrom.GetId(), hash, islock);
63+
m_is_manager.EnqueueInstantSendLock(pfrom.GetId(), hash, std::move(islock));
6464
}
6565
}
6666

0 commit comments

Comments
 (0)