Skip to content

Commit 5cdde27

Browse files
committed
Prevent -inf values when the closest mirror has a distance of 0
1 parent 58bcd26 commit 5cdde27

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

selection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func (h DefaultEngine) Selection(ctx *Context, cache *Cache, fileInfo *FileInfo,
142142
if m.Distance <= closestMirror*GetConfig().WeightDistributionRange {
143143
m.ComputedScore += int(float32(baseScore) - ((m.Distance / closestMirror) * closestMirror))
144144
} else if isPrimaryCountry(clientInfo, m.CountryFields) {
145-
m.ComputedScore += int(float32(baseScore)-((m.Distance/closestMirror)*closestMirror)) / 2
145+
m.ComputedScore += max(0, int(float32(baseScore)-((m.Distance/closestMirror)*closestMirror))) / 2
146146
} else if isAdditionalCountry(clientInfo, m.CountryFields) {
147147
m.ComputedScore += int(float32(baseScore) - closestMirror)
148148
}

0 commit comments

Comments
 (0)