Skip to content

Commit

Permalink
Merge #12276: Remove duplicate mapWallet lookups
Browse files Browse the repository at this point in the history
039425c [wallet] Remove duplicate mapWallet lookups (João Barbosa)

Pull request description:

Tree-SHA512: 8075925d2adb64737c691e988d74a37bc326711aaee2c37327361679c051f219fa500e14cbcdb6a169352bcdbab160e11df4276b2657e19e12908ee2d4444d30
  • Loading branch information
laanwj committed Jan 30, 2018
2 parents 288deac + 039425c commit 7936446
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/wallet/wallet.cpp
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7936446

Please sign in to comment.