aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-01-30 10:15:45 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2018-01-30 10:16:31 +0100
commit7936446268e2f63baa855d694df0243924b7e1a9 (patch)
tree171cf394e027d22e6054811727bc56ec8cad36b2 /src
parent288deacdbe088e72139cc4128f0d148a894bd10b (diff)
parent039425cf4fab56ea0e42564849a15485afa582ae (diff)
Merge #12276: Remove duplicate mapWallet lookups
039425c [wallet] Remove duplicate mapWallet lookups (João Barbosa) Pull request description: Tree-SHA512: 8075925d2adb64737c691e988d74a37bc326711aaee2c37327361679c051f219fa500e14cbcdb6a169352bcdbab160e11df4276b2657e19e12908ee2d4444d30
Diffstat (limited to 'src')
-rw-r--r--src/wallet/wallet.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 07a23ce249..2b8019395c 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -531,14 +531,11 @@ void CWallet::SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator> ran
int nMinOrderPos = std::numeric_limits<int>::max();
const CWalletTx* copyFrom = nullptr;
- for (TxSpends::iterator it = range.first; it != range.second; ++it)
- {
- const uint256& hash = it->second;
- int n = mapWallet[hash].nOrderPos;
- if (n < nMinOrderPos)
- {
- nMinOrderPos = n;
- copyFrom = &mapWallet[hash];
+ for (TxSpends::iterator it = range.first; it != range.second; ++it) {
+ const CWalletTx* wtx = &mapWallet[it->second];
+ if (wtx->nOrderPos < nMinOrderPos) {
+ nMinOrderPos = wtx->nOrderPos;;
+ copyFrom = wtx;
}
}
@@ -988,9 +985,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
bool CWallet::LoadToWallet(const CWalletTx& wtxIn)
{
uint256 hash = wtxIn.GetHash();
-
- mapWallet[hash] = wtxIn;
- CWalletTx& wtx = mapWallet[hash];
+ CWalletTx& wtx = mapWallet.emplace(hash, wtxIn).first->second;
wtx.BindWallet(this);
wtxOrdered.insert(std::make_pair(wtx.nOrderPos, TxPair(&wtx, nullptr)));
AddToSpends(hash);