diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-06-20 08:55:07 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-06-20 08:42:35 -0400 |
commit | fa8a341b88cabfd7f8d702db7cb9972b0804bf2a (patch) | |
tree | d3799d88cba30531c5503b089025ac68126567d8 /src/wallet/bdb.h | |
parent | fa021e9a5b7e930a3db0febb416942dea3a90a8f (diff) |
wallet: Replace CDataStream& with CDataStream&& where appropriate
The keys and values are only to be used once because their memory is set
to zero. Make that explicit by moving the bytes into the lower level
methods.
Diffstat (limited to 'src/wallet/bdb.h')
-rw-r--r-- | src/wallet/bdb.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/wallet/bdb.h b/src/wallet/bdb.h index a2eaf95001..91116afd01 100644 --- a/src/wallet/bdb.h +++ b/src/wallet/bdb.h @@ -189,10 +189,10 @@ class BerkeleyBatch }; private: - bool ReadKey(CDataStream& key, CDataStream& value); - bool WriteKey(CDataStream& key, CDataStream& value, bool overwrite=true); - bool EraseKey(CDataStream& key); - bool HasKey(CDataStream& key); + bool ReadKey(CDataStream&& key, CDataStream& value); + bool WriteKey(CDataStream&& key, CDataStream&& value, bool overwrite = true); + bool EraseKey(CDataStream&& key); + bool HasKey(CDataStream&& key); protected: Db* pdb; @@ -228,7 +228,7 @@ public: ssKey << key; CDataStream ssValue(SER_DISK, CLIENT_VERSION); - if (!ReadKey(ssKey, ssValue)) return false; + if (!ReadKey(std::move(ssKey), ssValue)) return false; try { ssValue >> value; return true; @@ -248,7 +248,7 @@ public: ssValue.reserve(10000); ssValue << value; - return WriteKey(ssKey, ssValue, fOverwrite); + return WriteKey(std::move(ssKey), std::move(ssValue), fOverwrite); } template <typename K> @@ -258,7 +258,7 @@ public: ssKey.reserve(1000); ssKey << key; - return EraseKey(ssKey); + return EraseKey(std::move(ssKey)); } template <typename K> @@ -268,7 +268,7 @@ public: ssKey.reserve(1000); ssKey << key; - return HasKey(ssKey); + return HasKey(std::move(ssKey)); } Dbc* GetCursor(); |