diff options
author | Marko Bencun <marko.bencun@monetas.net> | 2017-07-23 23:32:57 +0200 |
---|---|---|
committer | Marko Bencun <marko.bencun@monetas.net> | 2017-07-23 23:38:52 +0200 |
commit | 5cb3da04b8882ca975b4e3d6c089c64bbaf67d0d (patch) | |
tree | 0f2c1118633a04ea7920cf6f0a523cb113a4b281 /src/keystore.h | |
parent | 0c173a15ca1bf20999f74987988985508c9de463 (diff) |
keystore GetKeys(): return result instead of writing to reference
Issue: #10905
By returning the result, a few useless lines can be removed.
Return-value-optimization means there should be no copy.
Diffstat (limited to 'src/keystore.h')
-rw-r--r-- | src/keystore.h | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/keystore.h b/src/keystore.h index 965ae0c79a..059a657dc2 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -30,7 +30,7 @@ public: //! Check whether a key corresponding to a given address is present in the store. virtual bool HaveKey(const CKeyID &address) const =0; virtual bool GetKey(const CKeyID &address, CKey& keyOut) const =0; - virtual void GetKeys(std::set<CKeyID> &setAddress) const =0; + virtual std::set<CKeyID> GetKeys() const =0; virtual bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const =0; //! Support for BIP 0013 : see https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki @@ -71,18 +71,14 @@ public: } return result; } - void GetKeys(std::set<CKeyID> &setAddress) const override + std::set<CKeyID> GetKeys() const override { - setAddress.clear(); - { - LOCK(cs_KeyStore); - KeyMap::const_iterator mi = mapKeys.begin(); - while (mi != mapKeys.end()) - { - setAddress.insert((*mi).first); - mi++; - } + LOCK(cs_KeyStore); + std::set<CKeyID> set_address; + for (const auto& mi : mapKeys) { + set_address.insert(mi.first); } + return set_address; } bool GetKey(const CKeyID &address, CKey &keyOut) const override { |