From fa3f15f2dd94ae597a66037f5928fe4e90fe099d Mon Sep 17 00:00:00 2001 From: MacroFake Date: Sat, 30 Jul 2022 14:27:47 +0200 Subject: refactor: Avoid copies in FlatSigningProvider Merge --- src/wallet/scriptpubkeyman.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/wallet/scriptpubkeyman.cpp') diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 7ff017775e..ce8376fc7f 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -2080,7 +2080,7 @@ std::unique_ptr DescriptorScriptPubKeyMan::GetSigningProvid // Fetch SigningProvider from cache to avoid re-deriving auto it = m_map_signing_providers.find(index); if (it != m_map_signing_providers.end()) { - *out_keys = Merge(*out_keys, it->second); + out_keys->Merge(FlatSigningProvider{it->second}); } else { // Get the scripts, keys, and key origins for this script std::vector scripts_temp; @@ -2117,7 +2117,7 @@ bool DescriptorScriptPubKeyMan::SignTransaction(CMutableTransaction& tx, const s if (!coin_keys) { continue; } - *keys = Merge(*keys, *coin_keys); + keys->Merge(std::move(*coin_keys)); } return ::SignTransaction(tx, keys.get(), coins, sighash, input_errors); @@ -2178,7 +2178,7 @@ TransactionError DescriptorScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& std::unique_ptr keys = std::make_unique(); std::unique_ptr script_keys = GetSigningProvider(script, sign); if (script_keys) { - *keys = Merge(*keys, *script_keys); + keys->Merge(std::move(*script_keys)); } else { // Maybe there are pubkeys listed that we can sign for script_keys = std::make_unique(); @@ -2186,7 +2186,7 @@ TransactionError DescriptorScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& const CPubKey& pubkey = pk_pair.first; std::unique_ptr pk_keys = GetSigningProvider(pubkey); if (pk_keys) { - *keys = Merge(*keys, *pk_keys); + keys->Merge(std::move(*pk_keys)); } } for (const auto& pk_pair : input.m_tap_bip32_paths) { @@ -2198,7 +2198,7 @@ TransactionError DescriptorScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& fullpubkey.Set(b, b + 33); std::unique_ptr pk_keys = GetSigningProvider(fullpubkey); if (pk_keys) { - *keys = Merge(*keys, *pk_keys); + keys->Merge(std::move(*pk_keys)); } } } -- cgit v1.2.3