mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-28 16:08:27 +00:00
Deduplicate /state results
This commit is contained in:
parent
7c03546a9e
commit
98ae0f43af
1 changed files with 6 additions and 5 deletions
|
@ -1029,12 +1029,13 @@ func (t *txnReq) lookupMissingStateViaState(ctx context.Context, roomID, eventID
|
||||||
if err := state.Check(ctx, t.keys, nil); err != nil {
|
if err := state.Check(ctx, t.keys, nil); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Cache the results of this state lookup.
|
// Cache the results of this state lookup and deduplicate anything we already
|
||||||
for _, ev := range state.AuthEvents {
|
// have in the cache, freeing up memory.
|
||||||
t.cacheAndReturn(ev.Headered(roomVersion))
|
for i, ev := range state.AuthEvents {
|
||||||
|
state.AuthEvents[i] = t.cacheAndReturn(ev.Headered(roomVersion)).Unwrap()
|
||||||
}
|
}
|
||||||
for _, ev := range state.StateEvents {
|
for i, ev := range state.StateEvents {
|
||||||
t.cacheAndReturn(ev.Headered(roomVersion))
|
state.StateEvents[i] = t.cacheAndReturn(ev.Headered(roomVersion)).Unwrap()
|
||||||
}
|
}
|
||||||
return &state, nil
|
return &state, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue