mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +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)
|
||||
const
|
||||
{
|
||||
size_t ret{0};
|
||||
for_each(type, event::closure_idx{[&ret]
|
||||
(const event::idx &event_idx)
|
||||
if(!present())
|
||||
return count(type);
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue