0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-15 14:31:11 +01:00

ircd:Ⓜ️ Optimize the local_only() suite queries.

This commit is contained in:
Jason Volk 2019-09-07 16:55:44 -07:00
parent 71027c9383
commit e5b63e5c77

View file

@ -1035,12 +1035,18 @@ ircd::m::creator(const id::room &room_id)
bool bool
ircd::m::local_only(const room &room) ircd::m::local_only(const room &room)
{ {
// Branch to test if any remote users are joined to the room, meaning
// this result must be false; this is a fast query.
if(remote_joined(room))
return false;
const room::members members const room::members members
{ {
room room
}; };
return members.for_each([](const id::user &user_id) return members.for_each([]
(const id::user &user_id)
{ {
return my(user_id); return my(user_id);
}); });
@ -1054,12 +1060,16 @@ ircd::m::local_only(const room &room)
bool bool
ircd::m::local_joined(const room &room) ircd::m::local_joined(const room &room)
{ {
const room::origins origins const room::members members
{ {
room room
}; };
return !origins.empty() && origins.has(my_host()); return !members.for_each("join", []
(const id::user &user_id)
{
return my(user_id)? false : true; // false to break.
});
} }
/// Member(s) from another server are presently joined to the room. For example /// Member(s) from another server are presently joined to the room. For example
@ -1069,12 +1079,16 @@ ircd::m::local_joined(const room &room)
bool bool
ircd::m::remote_joined(const room &room) ircd::m::remote_joined(const room &room)
{ {
const room::origins origins const room::members members
{ {
room room
}; };
return !origins.empty() && !origins.only(my_host()); return !members.for_each("join", []
(const id::user &user_id)
{
return my(user_id)? true : false; // false to break.
});
} }
bool bool