0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-28 00:14:07 +01:00

ircd:Ⓜ️:room::state: Simplify util interface arguments.

This commit is contained in:
Jason Volk 2019-08-16 02:16:00 -07:00
parent 6e8111f25f
commit 125ff95875
3 changed files with 15 additions and 22 deletions

View file

@ -95,9 +95,9 @@ struct ircd::m::room::state
static event::idx next(const event::idx &); static event::idx next(const event::idx &);
static size_t prefetch(const state &, const string_view &, const event::idx_range &); 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 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(std::nothrow_t, const event::idx &);
static bool is(const event::idx &); static bool is(const event::idx &);
}; };

View file

@ -64,7 +64,7 @@ ircd::m::room::state::is(std::nothrow_t,
} }
size_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 db::txn txn
{ {
@ -74,7 +74,7 @@ ircd::m::room::state::purge_replaced(const state &state)
size_t ret(0); size_t ret(0);
m::room::messages it m::room::messages it
{ {
state.room_id, uint64_t(0) room_id, uint64_t(0)
}; };
if(!it) if(!it)
@ -82,7 +82,7 @@ ircd::m::room::state::purge_replaced(const state &state)
for(; it; ++it) 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 &) {})) if(!m::get(std::nothrow, event_idx, "state_key", [](const auto &) {}))
continue; continue;
@ -129,17 +129,22 @@ ircd::m::room::state::force_present(const m::event &event)
} }
size_t 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}; size_t ret{0};
m::room::messages it m::room::messages it
{ {
state.room_id, uint64_t(0) room_id, uint64_t(0)
}; };
if(!it) if(!it)
return ret; return ret;
const m::room::state state
{
room_id
};
db::txn txn db::txn txn
{ {
*m::dbs::events *m::dbs::events

View file

@ -9183,14 +9183,9 @@ console_cmd__room__state__purge__replaced(opt &out, const string_view &line)
m::room_id(param.at(0)) m::room_id(param.at(0))
}; };
const m::room::state state
{
room_id
};
const size_t ret const size_t ret
{ {
m::room::state::purge_replaced(state) m::room::state::purge_replaced(room_id)
}; };
out << "erased " << ret << std::endl; 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] m::rooms::for_each(opts, [&out]
(const m::room::id &room_id) (const m::room::id &room_id)
{ {
const m::room::state state
{
room_id
};
const size_t count const size_t count
{ {
m::room::state::rebuild_present(state) m::room::state::rebuild_present(room_id)
}; };
log::info log::info
@ -9242,11 +9232,9 @@ console_cmd__room__state__rebuild__present(opt &out, const string_view &line)
return true; return true;
} }
const m::room room{room_id};
const m::room::state state{room};
const size_t count const size_t count
{ {
state.rebuild_present(state) m::room::state::rebuild_present(room_id)
}; };
out << "done " << room_id << " " << count << std::endl; out << "done " << room_id << " " << count << std::endl;