From 125ff95875fd2cb00ce5a7b519b7cc24c4d7e185 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 16 Aug 2019 02:16:00 -0700 Subject: [PATCH] ircd::m::room::state: Simplify util interface arguments. --- include/ircd/m/room/state.h | 4 ++-- ircd/m_room.cc | 15 ++++++++++----- modules/console.cc | 18 +++--------------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/include/ircd/m/room/state.h b/include/ircd/m/room/state.h index 6b9ba958f..ad4cb5f92 100644 --- a/include/ircd/m/room/state.h +++ b/include/ircd/m/room/state.h @@ -95,9 +95,9 @@ struct ircd::m::room::state static event::idx next(const event::idx &); static size_t prefetch(const state &, const string_view &, const event::idx_range &); - static size_t rebuild_present(const state &); + static size_t rebuild_present(const room::id &); static bool force_present(const event &); - static size_t purge_replaced(const state &); + static size_t purge_replaced(const room::id &); static bool is(std::nothrow_t, const event::idx &); static bool is(const event::idx &); }; diff --git a/ircd/m_room.cc b/ircd/m_room.cc index 8607f3c50..b4a243ed0 100644 --- a/ircd/m_room.cc +++ b/ircd/m_room.cc @@ -64,7 +64,7 @@ ircd::m::room::state::is(std::nothrow_t, } size_t -ircd::m::room::state::purge_replaced(const state &state) +ircd::m::room::state::purge_replaced(const room::id &room_id) { db::txn txn { @@ -74,7 +74,7 @@ ircd::m::room::state::purge_replaced(const state &state) size_t ret(0); m::room::messages it { - state.room_id, uint64_t(0) + room_id, uint64_t(0) }; if(!it) @@ -82,7 +82,7 @@ ircd::m::room::state::purge_replaced(const state &state) for(; it; ++it) { - const m::event::idx &event_idx(it.event_idx()); + const m::event::idx &event_idx(it); if(!m::get(std::nothrow, event_idx, "state_key", [](const auto &) {})) continue; @@ -129,17 +129,22 @@ ircd::m::room::state::force_present(const m::event &event) } size_t -ircd::m::room::state::rebuild_present(const state &state) +ircd::m::room::state::rebuild_present(const room::id &room_id) { size_t ret{0}; m::room::messages it { - state.room_id, uint64_t(0) + room_id, uint64_t(0) }; if(!it) return ret; + const m::room::state state + { + room_id + }; + db::txn txn { *m::dbs::events diff --git a/modules/console.cc b/modules/console.cc index 0afc9fa94..adcdf3b3e 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -9183,14 +9183,9 @@ console_cmd__room__state__purge__replaced(opt &out, const string_view &line) m::room_id(param.at(0)) }; - const m::room::state state - { - room_id - }; - const size_t ret { - m::room::state::purge_replaced(state) + m::room::state::purge_replaced(room_id) }; out << "erased " << ret << std::endl; @@ -9219,14 +9214,9 @@ console_cmd__room__state__rebuild__present(opt &out, const string_view &line) m::rooms::for_each(opts, [&out] (const m::room::id &room_id) { - const m::room::state state - { - room_id - }; - const size_t count { - m::room::state::rebuild_present(state) + m::room::state::rebuild_present(room_id) }; log::info @@ -9242,11 +9232,9 @@ console_cmd__room__state__rebuild__present(opt &out, const string_view &line) return true; } - const m::room room{room_id}; - const m::room::state state{room}; const size_t count { - state.rebuild_present(state) + m::room::state::rebuild_present(room_id) }; out << "done " << room_id << " " << count << std::endl;