From d7437908cdf242626263ba9d5541addcddadc594 Mon Sep 17 00:00:00 2001 From: TheCharlatan Date: Fri, 28 Jul 2023 22:53:50 +0200 Subject: [PATCH] refactor: Split dbwrapper CDBIterator::Seek implementation Keep the generic serialization in the header, while moving leveldb-specifics to the implementation file. The context of this commit is an effort to decouple the dbwrapper header file from leveldb includes. To this end, the includes are moved to the dbwrapper implementation file. This is done as part of the kernel project to reduce the number of required includes for users of the kernel. --- src/dbwrapper.cpp | 6 ++++++ src/dbwrapper.h | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index ff2bc8b4e8..87d46f3192 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -306,6 +306,12 @@ bool CDBWrapper::IsEmpty() return !(it->Valid()); } +void CDBIterator::SeekImpl(Span ssKey) +{ + leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size()); + piter->Seek(slKey); +} + CDBIterator::~CDBIterator() { delete piter; } bool CDBIterator::Valid() const { return piter->Valid(); } void CDBIterator::SeekToFirst() { piter->SeekToFirst(); } diff --git a/src/dbwrapper.h b/src/dbwrapper.h index 9016111209..aa2b31b160 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -140,6 +140,8 @@ private: const CDBWrapper &parent; leveldb::Iterator *piter; + void SeekImpl(Span ssKey); + public: /** @@ -158,8 +160,7 @@ public: DataStream ssKey{}; ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE); ssKey << key; - leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size()); - piter->Seek(slKey); + SeekImpl(ssKey); } void Next();