mirror of
https://github.com/usememos/memos.git
synced 2026-11-19 10:29:11 +01:00
refactor: use the built-in max/min to simplify the code (#6430)
Signed-off-by: somasoil <somasoil@outlook.com>
This commit is contained in:
@@ -371,10 +371,7 @@ func (e *entry) retryAfter(rule Rule, now time.Time, cost int) time.Duration {
|
||||
// previous one, has decayed: overlap < (budget + 1) / current.
|
||||
ready = windowEnd.Add(decayTime(rule.Window, e.current, budget+1))
|
||||
}
|
||||
wait := ready.Sub(now)
|
||||
if wait < 0 {
|
||||
wait = 0
|
||||
}
|
||||
wait := max(ready.Sub(now), 0)
|
||||
// Floor plus one second lands strictly after the boundary even when the
|
||||
// wait is a whole number of seconds, and is never less than one.
|
||||
return time.Duration(math.Floor(wait.Seconds()))*time.Second + time.Second
|
||||
|
||||
Reference in New Issue
Block a user