Make 100 a const

This commit is contained in:
Till Faelligen 2024-01-20 20:34:04 +01:00
parent 6ddfa4441c
commit 0f15c6bf90
No known key found for this signature in database
GPG key ID: 3DF82D8AB9211D4E

View file

@ -90,6 +90,10 @@ type PerformBackfillRequest struct {
VirtualHost spec.ServerName `json:"virtual_host"`
}
// limitPrevEventIDs is the maximum of eventIDs we
// return when calling PrevEventIDs.
const limitPrevEventIDs = 100
// PrevEventIDs returns the prev_event IDs of either 100 backwards extremities or
// len(r.BackwardsExtremities). Limited to 100, due to Synapse/Dendrite stopping after reaching
// this limit. (which sounds sane)
@ -98,8 +102,8 @@ func (r *PerformBackfillRequest) PrevEventIDs() []string {
// Create a unique eventID map of either 100 or len(r.BackwardsExtremities).
// 100 since Synapse/Dendrite stops after reaching 100 events.
if len(r.BackwardsExtremities) > 100 {
uniqueIDs = make(map[string]struct{}, 100)
if len(r.BackwardsExtremities) > limitPrevEventIDs {
uniqueIDs = make(map[string]struct{}, limitPrevEventIDs)
} else {
uniqueIDs = make(map[string]struct{}, len(r.BackwardsExtremities))
}
@ -109,7 +113,7 @@ outerLoop:
for _, evID := range pes {
uniqueIDs[evID] = struct{}{}
// We found enough unique eventIDs.
if len(uniqueIDs) >= 100 {
if len(uniqueIDs) >= limitPrevEventIDs {
break outerLoop
}
}