From bc26a8f9b30ac71d641921a13b364e11f5d3636f Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 21 May 2018 00:19:27 -0700 Subject: [PATCH] ircd::m: Optimize user::rooms iteration event query. --- ircd/m/m.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ircd/m/m.cc b/ircd/m/m.cc index 3b0afac3c..d7b4542c2 100644 --- a/ircd/m/m.cc +++ b/ircd/m/m.cc @@ -2132,8 +2132,27 @@ ircd::m::user::rooms::for_each(const string_view &membership, const closure_bool &closure) const { + // Setup the list of event fields to fetch for the closure + static const event::keys keys + { + event::keys::include + { + "event_id", + "state_key", + "content", + } + }; + + const m::event::fetch::opts fopts + { + keys, user_room.fopts? user_room.fopts->gopts : db::gopts{} + }; + + const m::room::state state + { + user_room, &fopts + }; - const m::room::state state{user_room}; state.test("ircd.member", [&membership, &closure] (const m::event &event) {