mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-13 14:14:00 +01:00
Use DataStream where possible
This commit is contained in:
@@ -68,7 +68,7 @@ private:
|
||||
const CDBWrapper &parent;
|
||||
leveldb::WriteBatch batch;
|
||||
|
||||
CDataStream ssKey;
|
||||
DataStream ssKey{};
|
||||
CDataStream ssValue;
|
||||
|
||||
size_t size_estimate;
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
/**
|
||||
* @param[in] _parent CDBWrapper that this batch is to be submitted to
|
||||
*/
|
||||
explicit CDBBatch(const CDBWrapper &_parent) : parent(_parent), ssKey(SER_DISK, CLIENT_VERSION), ssValue(SER_DISK, CLIENT_VERSION), size_estimate(0) { };
|
||||
explicit CDBBatch(const CDBWrapper& _parent) : parent(_parent), ssValue(SER_DISK, CLIENT_VERSION), size_estimate(0){};
|
||||
|
||||
void Clear()
|
||||
{
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
void SeekToFirst();
|
||||
|
||||
template<typename K> void Seek(const K& key) {
|
||||
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
|
||||
DataStream ssKey{};
|
||||
ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
|
||||
ssKey << key;
|
||||
leveldb::Slice slKey((const char*)ssKey.data(), ssKey.size());
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
template<typename K> bool GetKey(K& key) {
|
||||
leveldb::Slice slKey = piter->key();
|
||||
try {
|
||||
CDataStream ssKey{MakeByteSpan(slKey), SER_DISK, CLIENT_VERSION};
|
||||
DataStream ssKey{MakeByteSpan(slKey)};
|
||||
ssKey >> key;
|
||||
} catch (const std::exception&) {
|
||||
return false;
|
||||
@@ -247,7 +247,7 @@ public:
|
||||
template <typename K, typename V>
|
||||
bool Read(const K& key, V& value) const
|
||||
{
|
||||
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
|
||||
DataStream ssKey{};
|
||||
ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
|
||||
ssKey << key;
|
||||
leveldb::Slice slKey((const char*)ssKey.data(), ssKey.size());
|
||||
@@ -289,7 +289,7 @@ public:
|
||||
template <typename K>
|
||||
bool Exists(const K& key) const
|
||||
{
|
||||
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
|
||||
DataStream ssKey{};
|
||||
ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
|
||||
ssKey << key;
|
||||
leveldb::Slice slKey((const char*)ssKey.data(), ssKey.size());
|
||||
@@ -331,7 +331,7 @@ public:
|
||||
template<typename K>
|
||||
size_t EstimateSize(const K& key_begin, const K& key_end) const
|
||||
{
|
||||
CDataStream ssKey1(SER_DISK, CLIENT_VERSION), ssKey2(SER_DISK, CLIENT_VERSION);
|
||||
DataStream ssKey1{}, ssKey2{};
|
||||
ssKey1.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
|
||||
ssKey2.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
|
||||
ssKey1 << key_begin;
|
||||
|
||||
Reference in New Issue
Block a user