]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: simplify gcResetGState
authorAustin Clements <austin@google.com>
Wed, 25 Feb 2015 03:29:33 +0000 (22:29 -0500)
committerAustin Clements <austin@google.com>
Wed, 25 Feb 2015 15:48:57 +0000 (15:48 +0000)
Since allglock is held in this function, there's no point to
tip-toeing around allgs.  Just use a for-range loop.

Change-Id: I1ee61c7e8cac8b8ebc8107c0c22f739db5db9840
Reviewed-on: https://go-review.googlesource.com/5882
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mgc.go

index e87d80618ab77318a4e5882469ab376a8524dda2..830bf879d4655fd70d8b23f381ef15c85c47003d 100644 (file)
@@ -600,18 +600,17 @@ func gcCopySpans() {
 
 // gcResetGState resets the GC state of all G's and returns the length
 // of allgs.
-func gcResetGState() int {
+func gcResetGState() (numgs int) {
        // This may be called during a concurrent phase, so make sure
        // allgs doesn't change.
        lock(&allglock)
-       local_allglen := allglen
-       for i := uintptr(0); i < local_allglen; i++ {
-               gp := allgs[i]
+       for _, gp := range allgs {
                gp.gcworkdone = false  // set to true in gcphasework
                gp.gcscanvalid = false // stack has not been scanned
        }
+       numgs = len(allgs)
        unlock(&allglock)
-       return int(local_allglen)
+       return
 }
 
 // Hooks for other packages