diff --git a/include/ircd/db/snapshot.h b/include/ircd/db/snapshot.h index 6a85f4582..e8f1ee09d 100644 --- a/include/ircd/db/snapshot.h +++ b/include/ircd/db/snapshot.h @@ -19,8 +19,8 @@ namespace rocksdb namespace ircd::db { - uint64_t sequence(const database::snapshot &); // Sequence of a snapshot - uint64_t sequence(const rocksdb::Snapshot *const &); + uint64_t sequence(const database::snapshot &) noexcept; // Sequence of a snapshot + uint64_t sequence(const rocksdb::Snapshot *) noexcept; } /// Database snapshot object. Maintaining this object will maintain a @@ -31,12 +31,41 @@ struct ircd::db::database::snapshot std::shared_ptr s; public: - operator const rocksdb::Snapshot *() const { return s.get(); } + operator const rocksdb::Snapshot *() const; - explicit operator bool() const { return bool(s); } - bool operator !() const { return !s; } + explicit operator bool() const; + bool operator !() const; explicit snapshot(database &); snapshot() = default; ~snapshot() noexcept; }; + +inline bool +ircd::db::database::snapshot::operator!() +const +{ + return !s; +} + +inline ircd::db::database::snapshot::operator +bool() +const +{ + return bool(s); +} + +inline ircd::db::database::snapshot::operator +const rocksdb::Snapshot *() +const +{ + return s.get(); +} + +inline uint64_t +ircd::db::sequence(const database::snapshot &s) +noexcept +{ + const rocksdb::Snapshot *const rs(s); + return sequence(rs); +} diff --git a/ircd/db_database.cc b/ircd/db_database.cc index a6cb3989f..c89a8de1c 100644 --- a/ircd/db_database.cc +++ b/ircd/db_database.cc @@ -2109,14 +2109,8 @@ const noexcept // uint64_t -ircd::db::sequence(const database::snapshot &s) -{ - const rocksdb::Snapshot *const rs(s); - return sequence(rs); -} - -uint64_t -ircd::db::sequence(const rocksdb::Snapshot *const &rs) +ircd::db::sequence(const rocksdb::Snapshot *const rs) +noexcept { return likely(rs)? rs->GetSequenceNumber() : 0ULL; }