]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: use built-in min function
authorMarcel Meyer <mm.marcelmeyer@gmail.com>
Thu, 10 Apr 2025 15:31:03 +0000 (15:31 +0000)
committerGopher Robot <gobot@golang.org>
Fri, 11 Apr 2025 15:22:09 +0000 (08:22 -0700)
Change-Id: I625c392864c97cefc2ac8f23612e3f62f7fbba23
GitHub-Last-Rev: 779f756850e7bf0cf2059ed0b4d412638c872f7e
GitHub-Pull-Request: golang/go#73313
Reviewed-on: https://go-review.googlesource.com/c/go/+/664016
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/runtime/proc.go

index 16339decbd5a94ea067d9c032bb0e067d8b4f4e8..c7ae71a13608fa47fb0c0e48231d9272161f6686 100644 (file)
@@ -6636,20 +6636,14 @@ func globrunqget() *g {
 
 // Try get a batch of G's from the global runnable queue.
 // sched.lock must be held.
-func globrunqgetbatch(max int32) (gp *g, q gQueue, qsize int32) {
+func globrunqgetbatch(n int32) (gp *g, q gQueue, qsize int32) {
        assertLockHeld(&sched.lock)
 
        if sched.runqsize == 0 {
                return
        }
 
-       n := sched.runqsize/gomaxprocs + 1
-       if n > sched.runqsize {
-               n = sched.runqsize
-       }
-       if n > max {
-               n = max
-       }
+       n = min(n, sched.runqsize, sched.runqsize/gomaxprocs+1)
 
        sched.runqsize -= n