Skip to content

Commit d743790

Browse files
committed
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.
1 parent ea8135d commit d743790

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/dbwrapper.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ bool CDBWrapper::IsEmpty()
306306
return !(it->Valid());
307307
}
308308

309+
void CDBIterator::SeekImpl(Span<const std::byte> ssKey)
310+
{
311+
leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size());
312+
piter->Seek(slKey);
313+
}
314+
309315
CDBIterator::~CDBIterator() { delete piter; }
310316
bool CDBIterator::Valid() const { return piter->Valid(); }
311317
void CDBIterator::SeekToFirst() { piter->SeekToFirst(); }

src/dbwrapper.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ class CDBIterator
140140
const CDBWrapper &parent;
141141
leveldb::Iterator *piter;
142142

143+
void SeekImpl(Span<const std::byte> ssKey);
144+
143145
public:
144146

145147
/**
@@ -158,8 +160,7 @@ class CDBIterator
158160
DataStream ssKey{};
159161
ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
160162
ssKey << key;
161-
leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size());
162-
piter->Seek(slKey);
163+
SeekImpl(ssKey);
163164
}
164165

165166
void Next();

0 commit comments

Comments
 (0)