diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2023-02-25 16:39:11 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2024-02-07 18:15:38 -0300 |
commit | d0943315b1d00905fe7f4513b2f3f47b88a99e8f (patch) | |
tree | 1371a861bba0c4ae02fac7b35ca9ab35ba7fe882 /src/wallet/wallet.cpp | |
parent | bba4f8dcb55de3ca4963711dc17882b43cb0bc4a (diff) | |
download | bitcoin-d0943315b1d00905fe7f4513b2f3f47b88a99e8f.tar.xz |
refactor: SetAddressBookWithDB, minimize number of map lookups
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r-- | src/wallet/wallet.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 55f8f1b9b5..e392f7f8aa 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2359,14 +2359,15 @@ bool CWallet::SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& add { LOCK(cs_wallet); std::map<CTxDestination, CAddressBookData>::iterator mi = m_address_book.find(address); - fUpdated = (mi != m_address_book.end() && !mi->second.IsChange()); - m_address_book[address].SetLabel(strName); + fUpdated = mi != m_address_book.end() && !mi->second.IsChange(); + + CAddressBookData& record = mi != m_address_book.end() ? mi->second : m_address_book[address]; + record.SetLabel(strName); is_mine = IsMine(address) != ISMINE_NO; if (new_purpose) { /* update purpose only if requested */ - purpose = m_address_book[address].purpose = new_purpose; - } else { - purpose = m_address_book[address].purpose; + record.purpose = new_purpose; } + purpose = record.purpose; } const std::string& encoded_dest = EncodeDestination(address); |