This commit is contained in:
Neil Alexander 2022-05-06 15:52:19 +01:00
parent 6f25419370
commit ff6ade35d7
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -325,11 +325,12 @@ func (u *latestEventsUpdater) calculateLatest(
} }
} }
// Start off with our new event. // Start off with our new unreferenced event. We're reusing the backing
// array here rather than allocating a new one.
u.latest = append(u.latest[:0], newStateAndRef) u.latest = append(u.latest[:0], newStateAndRef)
// If our new event references any of the existing forward extremities // If our new event references any of the existing forward extremities
// then they are no longer good candidates. // then they are no longer forward extremities, so remove them.
for _, prevEventID := range newEvent.PrevEventIDs() { for _, prevEventID := range newEvent.PrevEventIDs() {
delete(existingRefs, prevEventID) delete(existingRefs, prevEventID)
} }