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) {
entry.pushKV("address", EncodeDestination(address));
if (pwallet->mapAddressBook.count(address)) {
entry.pushKV("label", pwallet->mapAddressBook[address].name);
auto i = pwallet->mapAddressBook.find(address);
if (i != pwallet->mapAddressBook.end()) {
entry.pushKV("label", i->second.name);
if (IsDeprecatedRPCEnabled("accounts")) {
entry.pushKV("account", pwallet->mapAddressBook[address].name);
entry.pushKV("account", i->second.name);
}
}