mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-01 03:03:10 -06:00
Only append the single event
This commit is contained in:
parent
47e7045ca4
commit
6340e3e27f
|
|
@ -851,15 +851,20 @@ func (v *StateResolution) resolveConflictsV2(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only add auth events into the authEvents slice once, otherwise the
|
||||||
|
// check for the auth difference can become expensive and produce
|
||||||
|
// duplicate entries, which just waste memory and CPU time.
|
||||||
for _, event := range authSets[key] {
|
for _, event := range authSets[key] {
|
||||||
if _, ok := gotAuthEvents[event.EventID()]; !ok {
|
if _, ok := gotAuthEvents[event.EventID()]; !ok {
|
||||||
authEvents = append(authEvents, authSets[key]...)
|
authEvents = append(authEvents, event)
|
||||||
gotAuthEvents[event.EventID()] = struct{}{}
|
gotAuthEvents[event.EventID()] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let the GC get to this.
|
// Kill the reference to this so that the GC may pick it up, since we no
|
||||||
|
// longer need this after this point.
|
||||||
gotAuthEvents = nil // nolint:ineffassign
|
gotAuthEvents = nil // nolint:ineffassign
|
||||||
|
|
||||||
// This function helps us to work out whether an event exists in one of the
|
// This function helps us to work out whether an event exists in one of the
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue