From 507a44dc228a3817e7007f292a404fe6c9f66315 Mon Sep 17 00:00:00 2001 From: Jason7602 Date: Mon, 1 Nov 2021 23:27:45 +0800 Subject: [PATCH] sync: remove the redundant logic on sync.(*Pool).Put 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 Auto-Submit: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: David Chase TryBot-Result: Gopher Robot --- src/sync/pool.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/sync/pool.go b/src/sync/pool.go index d1abb6a8b71..ea142bb1817 100644 --- a/src/sync/pool.go +++ b/src/sync/pool.go @@ -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()