From 3b0f2b7ad56a4330364d85aacc022e0d5d893186 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 6 Dec 2020 12:01:28 -0800 Subject: [PATCH] ircd::m::room::state: Hoist event::fetch instance for faster seek in rebuilder. --- matrix/room_state.cc | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/matrix/room_state.cc b/matrix/room_state.cc index 3c0136156..3ab2e0152 100644 --- a/matrix/room_state.cc +++ b/matrix/room_state.cc @@ -942,16 +942,12 @@ ircd::m::room::state::rebuild::rebuild(const room::id &room_id) *m::dbs::events }; - ssize_t deleted(0); - present_state.for_each([&opts, &txn, &deleted] + m::event::fetch event; + ssize_t added(0), deleted(0); + present_state.for_each([&opts, &txn, &deleted, &event] (const auto &type, const auto &state_key, const auto &event_idx) { - const m::event::fetch &event - { - std::nothrow, event_idx - }; - - if(!event.valid) + if(!seek(std::nothrow, event, event_idx)) return true; auto _opts(opts); @@ -962,16 +958,10 @@ ircd::m::room::state::rebuild::rebuild(const room::id &room_id) return true; }); - ssize_t added(0); - history.for_each([&opts, &txn, &added, &room_id, &check_auth] + history.for_each([&opts, &txn, &added, &room_id, &check_auth, &event] (const auto &type, const auto &state_key, const auto &depth, const auto &event_idx) { - const m::event::fetch &event - { - std::nothrow, event_idx - }; - - if(!event.valid) + if(!seek(std::nothrow, event, event_idx)) return true; const auto &[pass, fail]