Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] [kernelheaders 1/n] Cleave LevelDB headers from our header tree #24676

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove leveldb reference from CDBIterator ctor as well
  • Loading branch information
dongcarl committed Mar 25, 2022
commit 43eb4d7cc9114cbcfff7ea49117640ecfd6d242d
14 changes: 7 additions & 7 deletions src/dbwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class DBIteratorImpl
void Next();
};

CDBIterator::CDBIterator(const CDBWrapper& _parent, leveldb::Iterator* _piter)
: m_impl(std::make_unique<DBIteratorImpl>(_parent, _piter)) {};
CDBIterator::CDBIterator(std::unique_ptr<DBIteratorImpl> impl)
: m_impl(std::move(impl)) {};

DBIteratorImpl::DBIteratorImpl(const CDBWrapper& _parent, leveldb::Iterator* _piter)
: parent(_parent), piter(_piter){};
Expand Down Expand Up @@ -248,7 +248,7 @@ class DBWrapperImpl

size_t DynamicMemoryUsage() const;

std::unique_ptr<CDBIterator> NewIterator();
std::unique_ptr<DBIteratorImpl> NewIterator();

bool IsEmpty();

Expand Down Expand Up @@ -463,12 +463,12 @@ size_t DBWrapperImpl::DynamicMemoryUsage() const

std::unique_ptr<CDBIterator> CDBWrapper::NewIterator()
{
return m_impl->NewIterator();
return std::make_unique<CDBIterator>(m_impl->NewIterator());
}

std::unique_ptr<CDBIterator> DBWrapperImpl::NewIterator()
std::unique_ptr<DBIteratorImpl> DBWrapperImpl::NewIterator()
{
return std::make_unique<CDBIterator>(m_parent, pdb->NewIterator(iteroptions));
return std::make_unique<DBIteratorImpl>(m_parent, pdb->NewIterator(iteroptions));
}

// Prefixed with null character to avoid collisions with other keys
Expand All @@ -493,7 +493,7 @@ bool CDBWrapper::IsEmpty()

bool DBWrapperImpl::IsEmpty()
{
std::unique_ptr<CDBIterator> it(NewIterator());
std::unique_ptr<DBIteratorImpl> it(NewIterator());
it->SeekToFirst();
return !(it->Valid());
}
Expand Down
6 changes: 2 additions & 4 deletions src/dbwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,10 @@ class CDBIterator
CDataStream doGetValue();

public:

/**
* @param[in] _parent Parent CDBWrapper instance.
* @param[in] _piter The original leveldb iterator.
* @param[in] impl DBIteratorImpl instance.
*/
CDBIterator(const CDBWrapper &_parent, leveldb::Iterator *_piter);
CDBIterator(std::unique_ptr<DBIteratorImpl> impl);
~CDBIterator();

bool Valid() const;
Expand Down