From b3f646b4788dc31239a6ee919c7ffa27109bed65 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 17 Sep 2019 10:35:58 -0700 Subject: [PATCH] ircd::m::room::events: Add prefetch() convenience to interface. --- include/ircd/m/room/events.h | 3 +++ ircd/m_room.cc | 41 ++++++++++++++++++++++++------------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/include/ircd/m/room/events.h b/include/ircd/m/room/events.h index 1caf8832d..285cc0909 100644 --- a/include/ircd/m/room/events.h +++ b/include/ircd/m/room/events.h @@ -71,6 +71,9 @@ struct ircd::m::room::events const m::event &fetch(std::nothrow_t); const m::event &fetch(); + bool prefetch(const string_view &event_prop); + bool prefetch(); // uses property keys from any fetch::opts supplied. + bool seek_idx(const event::idx &); bool seek(const uint64_t &depth = -1); bool seek(const event::id &); diff --git a/ircd/m_room.cc b/ircd/m_room.cc index 720972412..1094929e6 100644 --- a/ircd/m_room.cc +++ b/ircd/m_room.cc @@ -1800,6 +1800,33 @@ catch(const db::not_found &e) return false; } +bool +ircd::m::room::events::prefetch() +{ + assert(_event.fopts); + return m::prefetch(event_idx(), *_event.fopts); +} + +bool +ircd::m::room::events::prefetch(const string_view &event_prop) +{ + return m::prefetch(event_idx(), event_prop); +} + +const ircd::m::event & +ircd::m::room::events::fetch() +{ + m::seek(_event, event_idx()); + return _event; +} + +const ircd::m::event & +ircd::m::room::events::fetch(std::nothrow_t) +{ + m::seek(_event, event_idx(), std::nothrow); + return _event; +} + ircd::m::room::events::operator ircd::m::event::idx() const @@ -1840,20 +1867,6 @@ const return std::get<1>(part); } -const ircd::m::event & -ircd::m::room::events::fetch() -{ - m::seek(_event, event_idx()); - return _event; -} - -const ircd::m::event & -ircd::m::room::events::fetch(std::nothrow_t) -{ - m::seek(_event, event_idx(), std::nothrow); - return _event; -} - // // room::state //