mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd:Ⓜ️:room: Optimize the state::count(type) to elide value query.
This commit is contained in:
parent
89e3838c4f
commit
3d982a3042
1 changed files with 14 additions and 5 deletions
|
@ -2149,12 +2149,21 @@ size_t
|
||||||
ircd::m::room::state::count(const string_view &type)
|
ircd::m::room::state::count(const string_view &type)
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
size_t ret{0};
|
if(!present())
|
||||||
for_each(type, event::closure_idx{[&ret]
|
return count(type);
|
||||||
(const event::idx &event_idx)
|
|
||||||
|
const db::gopts &opts
|
||||||
{
|
{
|
||||||
++ret;
|
this->fopts? this->fopts->gopts : db::gopts{}
|
||||||
}});
|
};
|
||||||
|
|
||||||
|
size_t ret(0);
|
||||||
|
auto &column{dbs::room_state};
|
||||||
|
for(auto it{column.begin(room_id, opts)}; bool(it); ++it)
|
||||||
|
{
|
||||||
|
const auto key(dbs::room_state_key(it->first));
|
||||||
|
ret += std::get<0>(key) == type;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue