From: cuishuang Date: Mon, 31 Mar 2025 10:10:43 +0000 (+0800) Subject: all: use built-in max/min to simplify the code X-Git-Tag: go1.25rc1~528 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=465097b2b5f9d8178fafac8a85a3cd331758b643;p=gostls13.git 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 Reviewed-by: Dmitri Shuralyov Auto-Submit: Dmitri Shuralyov Reviewed-by: Damien Neil LUCI-TryBot-Result: Go LUCI --- diff --git a/src/net/timeout_test.go b/src/net/timeout_test.go index 09adb9bdca..0d009f6999 100644 --- a/src/net/timeout_test.go +++ b/src/net/timeout_test.go @@ -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. diff --git a/src/os/timeout_test.go b/src/os/timeout_test.go index e0d2328ba1..5535beece8 100644 --- a/src/os/timeout_test.go +++ b/src/os/timeout_test.go @@ -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.