]> Cypherpunks repositories - gostls13.git/commitdiff
all: use built-in max/min to simplify the code
authorcuishuang <imcusg@gmail.com>
Mon, 31 Mar 2025 10:10:43 +0000 (18:10 +0800)
committerGopher Robot <gobot@golang.org>
Mon, 7 Apr 2025 19:59:28 +0000 (12:59 -0700)
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>

src/net/timeout_test.go
src/os/timeout_test.go

index 09adb9bdca4cd7319ab0dedf058a050775f19adc..0d009f6999386529add54f7a38b25dc8cf04c55b 100644 (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.
index e0d2328ba148986397c0a0334a783e86f5f548f0..5535beece8a218d3e20cdc280d2f1e2c43d36c68 100644 (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.