refactor: Avoid extra lookups of mapAddressBook in listunspent RPC

This commit is contained in:
João Barbosa 2018-05-03 11:32:57 +01:00
parent d76962e056
commit a59dac35ab

View file

@ -3171,10 +3171,11 @@ UniValue listunspent(const JSONRPCRequest& request)
if (fValidAddress) { if (fValidAddress) {
entry.pushKV("address", EncodeDestination(address)); entry.pushKV("address", EncodeDestination(address));
if (pwallet->mapAddressBook.count(address)) { auto i = pwallet->mapAddressBook.find(address);
entry.pushKV("label", pwallet->mapAddressBook[address].name); if (i != pwallet->mapAddressBook.end()) {
entry.pushKV("label", i->second.name);
if (IsDeprecatedRPCEnabled("accounts")) { if (IsDeprecatedRPCEnabled("accounts")) {
entry.pushKV("account", pwallet->mapAddressBook[address].name); entry.pushKV("account", i->second.name);
} }
} }