Skip to content

Commit a59dac3

Browse files
committed
refactor: Avoid extra lookups of mapAddressBook in listunspent RPC
1 parent d76962e commit a59dac3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3171,10 +3171,11 @@ UniValue listunspent(const JSONRPCRequest& request)
31713171
if (fValidAddress) {
31723172
entry.pushKV("address", EncodeDestination(address));
31733173

3174-
if (pwallet->mapAddressBook.count(address)) {
3175-
entry.pushKV("label", pwallet->mapAddressBook[address].name);
3174+
auto i = pwallet->mapAddressBook.find(address);
3175+
if (i != pwallet->mapAddressBook.end()) {
3176+
entry.pushKV("label", i->second.name);
31763177
if (IsDeprecatedRPCEnabled("accounts")) {
3177-
entry.pushKV("account", pwallet->mapAddressBook[address].name);
3178+
entry.pushKV("account", i->second.name);
31783179
}
31793180
}
31803181

0 commit comments

Comments
 (0)