]> Cypherpunks repositories - gostls13.git/commitdiff
sync: remove the redundant logic on sync.(*Pool).Put
authorJason7602 <jansonzhe@gmail.com>
Mon, 1 Nov 2021 15:27:45 +0000 (23:27 +0800)
committerGopher Robot <gobot@golang.org>
Sun, 8 May 2022 17:23:05 +0000 (17:23 +0000)
When the procUnpin is placed after shared.pushHead, there is
no need for x as a flag to indicate the previous process.

This CL can make the logic clear, and at the same time reduce
a redundant judgment.

Change-Id: I34ec9ba4cb5b5dbdf13a8f158b90481fed248cf5
Reviewed-on: https://go-review.googlesource.com/c/go/+/360059
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/sync/pool.go

index d1abb6a8b716136ccd2a5594692b76ec2e460186..ea142bb181796de4dea421e471c7cf3c0b96244e 100644 (file)
@@ -102,9 +102,7 @@ func (p *Pool) Put(x any) {
        l, _ := p.pin()
        if l.private == nil {
                l.private = x
-               x = nil
-       }
-       if x != nil {
+       } else {
                l.shared.pushHead(x)
        }
        runtime_procUnpin()