Skip to content

Commit

Permalink
Remove inlining from iterator methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Jun 10, 2024
1 parent 7eec4c8 commit 7099a1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 39 deletions.
39 changes: 6 additions & 33 deletions include/bitcoin/database/impl/primitives/iterator.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@ namespace libbitcoin {
namespace database {

TEMPLATE
INLINE CLASS::iterator(const memory_ptr& data, const Link& start,
CLASS::iterator(const memory_ptr& data, const Link& start,
const Key& key) NOEXCEPT
: memory_(data), key_(key), link_(to_match(start))
{
}

TEMPLATE
INLINE bool CLASS::advance() NOEXCEPT
bool CLASS::advance() NOEXCEPT
{
return !((link_ = to_next(link_))).is_terminal();
}

TEMPLATE
INLINE const Link& CLASS::self() const NOEXCEPT
const Link& CLASS::self() const NOEXCEPT
{
return link_;
}

TEMPLATE
INLINE const memory_ptr& CLASS::get() const NOEXCEPT
const memory_ptr& CLASS::get() const NOEXCEPT
{
return memory_;
}
Expand All @@ -56,7 +56,7 @@ INLINE const memory_ptr& CLASS::get() const NOEXCEPT
// ----------------------------------------------------------------------------

TEMPLATE
INLINE Link CLASS::to_match(Link link) const NOEXCEPT
Link CLASS::to_match(Link link) const NOEXCEPT
{
// Because of this !link_.is_terminal() subsequently guards both.
if (!memory_)
Expand All @@ -82,7 +82,7 @@ INLINE Link CLASS::to_match(Link link) const NOEXCEPT
}

TEMPLATE
INLINE Link CLASS::to_next(Link link) const NOEXCEPT
Link CLASS::to_next(Link link) const NOEXCEPT
{
while (!link.is_terminal())
{
Expand Down Expand Up @@ -110,33 +110,6 @@ INLINE Link CLASS::to_next(Link link) const NOEXCEPT
return std::move(link);
}

////TEMPLATE
////INLINE bool CLASS::is_match() const NOEXCEPT
////{
//// if (link_.is_terminal())
//// return false;
////
//// const auto offset = memory_->offset(link_to_position(link_));
//// if (is_null(offset))
//// return false;
////
//// const auto key = std::next(offset, Link::size);
//// return is_zero(std::memcmp(key_.data(), key, key_size));
////}
////
////TEMPLATE
////INLINE Link CLASS::get_next() const NOEXCEPT
////{
//// if (link_.is_terminal())
//// return {};
////
//// const auto offset = memory_->offset(link_to_position(link_));
//// if (is_null(offset))
//// return {};
////
//// return { system::unsafe_array_cast<uint8_t, Link::size>(offset) };
////}

// private
// ----------------------------------------------------------------------------

Expand Down
12 changes: 6 additions & 6 deletions include/bitcoin/database/primitives/iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,22 @@ class iterator

/// This advances to first match (or terminal).
/// Key must be passed as an l-value as it is held by reference.
INLINE iterator(const memory_ptr& data, const Link& start,
iterator(const memory_ptr& data, const Link& start,
const Key& key) NOEXCEPT;

/// Advance to and return next iterator.
INLINE bool advance() NOEXCEPT;
bool advance() NOEXCEPT;

/// Advance to next match and return false if terminal (not found).
INLINE const Link& self() const NOEXCEPT;
const Link& self() const NOEXCEPT;

/// Access the underlying memory pointer.
// TODO: for use by hashmap, make exclusive via friend.
INLINE const memory_ptr& get() const NOEXCEPT;
const memory_ptr& get() const NOEXCEPT;

protected:
INLINE Link to_match(Link link) const NOEXCEPT;
INLINE Link to_next(Link link) const NOEXCEPT;
Link to_match(Link link) const NOEXCEPT;
Link to_next(Link link) const NOEXCEPT;

private:
static constexpr auto key_size = array_count<Key>;
Expand Down

0 comments on commit 7099a1b

Please sign in to comment.