mirror of
https://github.com/matrix-construct/construct
synced 2024-12-01 19:22:53 +01:00
modules/client/sync: Optimize the room state iteration strategy.
This commit is contained in:
parent
2d90469f6b
commit
36c1b359ab
1 changed files with 7 additions and 7 deletions
|
@ -1004,24 +1004,24 @@ ircd::m::sync::polylog::room_state(shortpoll &sp,
|
||||||
|
|
||||||
m::room::state state
|
m::room::state state
|
||||||
{
|
{
|
||||||
room, &fopts
|
room
|
||||||
};
|
};
|
||||||
|
|
||||||
if(bool(prefetch_state))
|
if(bool(prefetch_state))
|
||||||
state.prefetch(sp.since, sp.current);
|
state.prefetch(sp.since, sp.current);
|
||||||
|
|
||||||
state.for_each([&]
|
state.for_each([&sp, &array]
|
||||||
(const m::event &event)
|
(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;
|
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;
|
return;
|
||||||
|
|
||||||
array.append(event);
|
array.append(event);
|
||||||
|
|
Loading…
Reference in a new issue