0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 18:22:50 +01:00

ircd:Ⓜ️:room::events: Add optional bool to convey validity on nothrow overload; minor inline.

This commit is contained in:
Jason Volk 2023-02-10 11:35:12 -08:00
parent 1910d8e85e
commit ae5af6a7ed
2 changed files with 13 additions and 11 deletions

View file

@ -80,10 +80,10 @@ struct ircd::m::room::events
auto &operator--() { return ++it; }
// Fetch the actual event data at the iterator's position
const m::event &operator*();
const m::event *operator->() { return &operator*(); }
const m::event &fetch(std::nothrow_t);
const m::event &fetch(std::nothrow_t, bool *valid = nullptr);
const m::event &fetch();
const m::event &operator*() { return fetch(std::nothrow); }
const m::event *operator->() { return &operator*(); }
// Prefetch the actual event data at the iterator's position (async)
bool prefetch(const string_view &event_prop);

View file

@ -321,18 +321,20 @@ ircd::m::room::events::fetch()
}
const ircd::m::event &
ircd::m::room::events::fetch(std::nothrow_t)
ircd::m::room::events::fetch(std::nothrow_t,
bool *const valid_)
{
m::seek(std::nothrow, _event, event_idx());
const bool valid
{
m::seek(std::nothrow, _event, event_idx())
};
if(valid_)
*valid_ = valid;
return _event;
}
const ircd::m::event &
ircd::m::room::events::operator*()
{
return fetch(std::nothrow);
};
bool
ircd::m::room::events::preseek(const uint64_t &depth)
{