0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-29 00:03:45 +02:00

ircd::db: Shorter paths to valid(iterator); strip noexcept; hot annotate uninlineable.

This commit is contained in:
Jason Volk 2023-02-17 20:28:20 -08:00
parent 6e6afb9d30
commit 23c8a6c5cb
3 changed files with 21 additions and 24 deletions

View file

@ -86,7 +86,7 @@ struct ircd::db::cell
cell(column, const string_view &index = {}, const gopts & = {}); cell(column, const string_view &index = {}, const gopts & = {});
cell(database &, const string_view &column, const string_view &index, const gopts & = {}); cell(database &, const string_view &column, const string_view &index, const gopts & = {});
cell(database &, const string_view &column, const gopts & = {}); cell(database &, const string_view &column, const gopts & = {});
cell(); cell() noexcept;
cell(cell &&) noexcept; cell(cell &&) noexcept;
cell(const cell &) = delete; cell(const cell &) = delete;
cell &operator=(cell &&) noexcept; cell &operator=(cell &&) noexcept;
@ -146,3 +146,10 @@ const
{ {
return val(); return val();
} }
inline bool
ircd::db::cell::valid()
const
{
return it && db::valid(*it);
}

View file

@ -51,8 +51,8 @@ struct ircd::db::column::const_iterator_base
explicit operator database::snapshot &(); explicit operator database::snapshot &();
explicit operator gopts &(); explicit operator gopts &();
operator bool() const noexcept; operator bool() const;
bool operator!() const noexcept; bool operator!() const;
const value_type *operator->() const; const value_type *operator->() const;
const value_type &operator*() const; const value_type &operator*() const;
@ -101,11 +101,18 @@ const
inline bool inline bool
ircd::db::column::const_iterator_base::operator!() ircd::db::column::const_iterator_base::operator!()
const noexcept const
{ {
return !static_cast<bool>(*this); return !static_cast<bool>(*this);
} }
inline ircd::db::column::const_iterator_base::operator
bool()
const
{
return it && valid(*it);
}
inline ircd::db::column::const_iterator_base::operator inline ircd::db::column::const_iterator_base::operator
gopts &() gopts &()
{ {

View file

@ -2146,7 +2146,9 @@ template bool ircd::db::seek<ircd::db::pos>(cell &, const pos &, gopts);
template bool ircd::db::seek<ircd::string_view>(cell &, const string_view &, gopts); template bool ircd::db::seek<ircd::string_view>(cell &, const string_view &, gopts);
// Linkage for incomplete rocksdb::Iterator // Linkage for incomplete rocksdb::Iterator
[[gnu::hot]]
ircd::db::cell::cell() ircd::db::cell::cell()
noexcept
{ {
} }
@ -2235,6 +2237,7 @@ noexcept
} }
// Linkage for incomplete rocksdb::Iterator // Linkage for incomplete rocksdb::Iterator
[[gnu::hot]]
ircd::db::cell::~cell() ircd::db::cell::~cell()
noexcept noexcept
{ {
@ -2334,13 +2337,6 @@ const
return valid() && db::valid_lte(*it, s); return valid() && db::valid_lte(*it, s);
} }
bool
ircd::db::cell::valid()
const
{
return bool(it) && db::valid(*it);
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// db/domain.h // db/domain.h
@ -3681,18 +3677,6 @@ const
return val; return val;
} }
ircd::db::column::const_iterator_base::operator bool()
const noexcept
{
if(!it)
return false;
if(!valid(*it))
return false;
return true;
}
bool bool
ircd::db::operator!=(const column::const_iterator_base &a, const column::const_iterator_base &b) ircd::db::operator!=(const column::const_iterator_base &a, const column::const_iterator_base &b)
noexcept noexcept
@ -5316,7 +5300,6 @@ namespace ircd::db
} }
/// Convert our options structure into RocksDB's options structure. /// Convert our options structure into RocksDB's options structure.
[[gnu::hot]]
rocksdb::ReadOptions rocksdb::ReadOptions
ircd::db::make_opts(const gopts &opts) ircd::db::make_opts(const gopts &opts)
noexcept noexcept