Skip to content

Commit

Permalink
Prevent -inf values when the closest mirror has a distance of 0
Browse files Browse the repository at this point in the history
  • Loading branch information
etix committed Oct 3, 2014
1 parent 58bcd26 commit 5cdde27
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (h DefaultEngine) Selection(ctx *Context, cache *Cache, fileInfo *FileInfo,
if m.Distance <= closestMirror*GetConfig().WeightDistributionRange {
m.ComputedScore += int(float32(baseScore) - ((m.Distance / closestMirror) * closestMirror))
} else if isPrimaryCountry(clientInfo, m.CountryFields) {
m.ComputedScore += int(float32(baseScore)-((m.Distance/closestMirror)*closestMirror)) / 2
m.ComputedScore += max(0, int(float32(baseScore)-((m.Distance/closestMirror)*closestMirror))) / 2
} else if isAdditionalCountry(clientInfo, m.CountryFields) {
m.ComputedScore += int(float32(baseScore) - closestMirror)
}
Expand Down

0 comments on commit 5cdde27

Please sign in to comment.