0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-12 13:01:07 +01:00

ircd::db::database::snapshot: Minor cleanup; inline, noexcept.

This commit is contained in:
Jason Volk 2023-02-16 15:59:13 -08:00
parent 4edf7f0052
commit d48e6ccb8d
2 changed files with 36 additions and 13 deletions

View file

@ -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<const rocksdb::Snapshot> 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);
}

View file

@ -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;
}