From d1193ab407641e692a15bd6784c61fecfb1cb4e4 Mon Sep 17 00:00:00 2001 From: clemahieu Date: Tue, 3 Jul 2018 09:04:55 +0100 Subject: [PATCH] Remove store_entry class since it's effectively just a pair of rai::mdb_val --- rai/blockstore.cpp | 37 +++++++++++++------------------------ rai/blockstore.hpp | 18 +++--------------- 2 files changed, 16 insertions(+), 39 deletions(-) diff --git a/rai/blockstore.cpp b/rai/blockstore.cpp index 428734d8..706aab83 100644 --- a/rai/blockstore.cpp +++ b/rai/blockstore.cpp @@ -54,26 +54,9 @@ public: }; } -rai::store_entry::store_entry () : -first (0, nullptr), -second (0, nullptr) +std::pair * rai::store_iterator::operator-> () { -} - -void rai::store_entry::clear () -{ - first = { 0, nullptr }; - second = { 0, nullptr }; -} - -rai::store_entry * rai::store_entry::operator-> () -{ - return this; -} - -rai::store_entry & rai::store_iterator::operator-> () -{ - return current; + return ¤t; } rai::store_iterator::store_iterator (MDB_txn * transaction_a, MDB_dbi db_a) : @@ -90,7 +73,7 @@ cursor (nullptr) } else { - current.clear (); + clear (); } } @@ -114,7 +97,7 @@ cursor (nullptr) } else { - current.clear (); + clear (); } } @@ -139,7 +122,7 @@ rai::store_iterator & rai::store_iterator::operator++ () auto status (mdb_cursor_get (cursor, ¤t.first.value, ¤t.second.value, MDB_NEXT)); if (status == MDB_NOTFOUND) { - current.clear (); + clear (); } return *this; } @@ -150,7 +133,7 @@ void rai::store_iterator::next_dup () auto status (mdb_cursor_get (cursor, ¤t.first.value, ¤t.second.value, MDB_NEXT_DUP)); if (status == MDB_NOTFOUND) { - current.clear (); + clear (); } } @@ -163,7 +146,7 @@ rai::store_iterator & rai::store_iterator::operator= (rai::store_iterator && oth cursor = other_a.cursor; other_a.cursor = nullptr; current = other_a.current; - other_a.current.clear (); + other_a.clear (); return *this; } @@ -181,6 +164,12 @@ bool rai::store_iterator::operator!= (rai::store_iterator const & other_a) const return !(*this == other_a); } +void rai::store_iterator::clear () +{ + current.first = rai::mdb_val (); + current.second = rai::mdb_val (); +} + rai::store_iterator rai::block_store::block_info_begin (MDB_txn * transaction_a, rai::block_hash const & hash_a) { rai::store_iterator result (transaction_a, blocks_info, rai::mdb_val (hash_a)); diff --git a/rai/blockstore.hpp b/rai/blockstore.hpp index 000d79b3..1ffe5952 100644 --- a/rai/blockstore.hpp +++ b/rai/blockstore.hpp @@ -4,19 +4,6 @@ namespace rai { -/** - * The value produced when iterating with \ref store_iterator - */ -class store_entry -{ -public: - store_entry (); - void clear (); - store_entry * operator-> (); - rai::mdb_val first; - rai::mdb_val second; -}; - /** * Iterates the key/value pairs of a transaction */ @@ -33,11 +20,12 @@ public: void next_dup (); rai::store_iterator & operator= (rai::store_iterator &&); rai::store_iterator & operator= (rai::store_iterator const &) = delete; - rai::store_entry & operator-> (); + std::pair * operator-> (); bool operator== (rai::store_iterator const &) const; bool operator!= (rai::store_iterator const &) const; + void clear (); MDB_cursor * cursor; - rai::store_entry current; + std::pair current; }; /**