Skip to content

Commit

Permalink
Remove unnecessary caching of slice length
Browse files Browse the repository at this point in the history
  • Loading branch information
annismckenzie authored and dmitshur committed Dec 5, 2016
1 parent 2064d2b commit ef638b6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions times.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,12 @@ func CustomRelTime(a, b time.Time, albl, blbl string, magnitudes []RelTimeMagnit
diff = a.Sub(b)
}

lenMag := len(magnitudes)
n := sort.Search(lenMag, func(i int) bool {
n := sort.Search(len(magnitudes), func(i int) bool {
return magnitudes[i].D >= diff
})

if n >= lenMag {
n = lenMag - 1
if n >= len(magnitudes) {
n = len(magnitudes) - 1
}
mag := magnitudes[n]
args := []interface{}{}
Expand Down

0 comments on commit ef638b6

Please sign in to comment.