all: use built-in max/min to simplify the code

Change-Id: I309d93d6ebf0feb462217a344d5f02c190220752
Reviewed-on: https://go-review.googlesource.com/c/go/+/661737
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
cuishuang 2025-03-31 18:10:43 +08:00 committed by Gopher Robot
parent d584d2b3dd
commit 465097b2b5
2 changed files with 2 additions and 8 deletions

View File

@ -730,10 +730,7 @@ func nextTimeout(actual time.Duration) (next time.Duration, ok bool) {
// duration by any significant margin. Try the next attempt with an arbitrary
// factor above that, so that our growth curve is at least exponential.
next = actual * 5 / 4
if next > maxDynamicTimeout {
return maxDynamicTimeout, true
}
return next, true
return min(next, maxDynamicTimeout), true
}
// There is a very similar copy of this in os/timeout_test.go.

View File

@ -282,10 +282,7 @@ func nextTimeout(actual time.Duration) (next time.Duration, ok bool) {
// duration by any significant margin. Try the next attempt with an arbitrary
// factor above that, so that our growth curve is at least exponential.
next = actual * 5 / 4
if next > maxDynamicTimeout {
return maxDynamicTimeout, true
}
return next, true
return min(next, maxDynamicTimeout), true
}
// There is a very similar copy of this in net/timeout_test.go.