From 36c1b359ab160785e36def2be89cea4866efc280 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 19 Dec 2018 14:57:44 -0800 Subject: [PATCH] modules/client/sync: Optimize the room state iteration strategy. --- modules/client/sync.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/client/sync.cc b/modules/client/sync.cc index f7a346715..864bd94b7 100644 --- a/modules/client/sync.cc +++ b/modules/client/sync.cc @@ -1004,24 +1004,24 @@ ircd::m::sync::polylog::room_state(shortpoll &sp, m::room::state state { - room, &fopts + room }; if(bool(prefetch_state)) state.prefetch(sp.since, sp.current); - state.for_each([&] - (const m::event &event) + state.for_each([&sp, &array] + (const m::event::idx &event_idx) { - if(at<"depth"_>(event) >= int64_t(sp.state_at)) + if(event_idx < sp.since || event_idx >= sp.current) return; - const auto &event_idx + const event::fetch event { - index(event, std::nothrow) + event_idx, std::nothrow, &fopts }; - if(event_idx < sp.since || event_idx >= sp.current) + if(!event.valid || at<"depth"_>(event) >= int64_t(sp.state_at)) return; array.append(event);