Skip to content

Commit 15209d9

Browse files
committed
consensus, refactor: Avoid CScriptCheck::swap in CheckInputScripts
1 parent f4e42a7 commit 15209d9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/validation.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,8 +1815,7 @@ bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
18151815
// Verify signature
18161816
CScriptCheck check(txdata.m_spent_outputs[i], tx, i, flags, cacheSigStore, &txdata);
18171817
if (pvChecks) {
1818-
pvChecks->push_back(CScriptCheck());
1819-
check.swap(pvChecks->back());
1818+
pvChecks->emplace_back(std::move(check));
18201819
} else if (!check()) {
18211820
if (flags & STANDARD_NOT_MANDATORY_VERIFY_FLAGS) {
18221821
// Check whether the failure was caused by a

src/validation.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,11 @@ class CScriptCheck
322322
CScriptCheck(const CTxOut& outIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, PrecomputedTransactionData* txdataIn) :
323323
m_tx_out(outIn), ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), cacheStore(cacheIn), error(SCRIPT_ERR_UNKNOWN_ERROR), txdata(txdataIn) { }
324324

325+
CScriptCheck(const CScriptCheck&) = delete;
326+
CScriptCheck& operator=(const CScriptCheck&) = delete;
327+
CScriptCheck(CScriptCheck&&) = default;
328+
CScriptCheck& operator=(CScriptCheck&&) = default;
329+
325330
bool operator()();
326331

327332
void swap(CScriptCheck& check) noexcept

0 commit comments

Comments
 (0)