0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-16 08:58:20 +02:00

ircd:Ⓜ️ Add optimized room::members event iteration for present membership=join.

This commit is contained in:
Jason Volk 2018-03-03 06:21:59 -08:00
parent c676d56dcd
commit 9cf25a2d3b

View file

@ -628,7 +628,32 @@ ircd::m::room::members::test(const string_view &membership,
const event::closure_bool &view)
const
{
//TODO: optimize with sequential column strat
// joined members optimization. Only possible when seeking
// membership="join" on the present state of the room.
if(!room.event_id && membership == "join")
{
const room::state state{room};
const room::origins origins{room};
return origins._test_([&view, &state]
(const string_view &key)
{
const string_view &member
{
end(split(key, "@").first), end(key)
};
bool ret{false};
static const string_view type{"m.room.member"};
state.get(type, member, [&view, &ret]
(const m::event &event)
{
ret = view(event);
});
return ret;
});
}
return test([&membership, &view](const event &event)
{
if(at<"membership"_>(event) == membership)