mirror of https://github.com/golang/go.git
cmd/link: remove unnecessary use of sync.Once alongside sync.Mutex
There does not seem to be any point to this sync.Once. I noticed because I was surveying uses of sync.Once to understand usage patterns. This seems to be a dreg left over from some earlier instance of the code. Change-Id: I99dd258d865a41d0e8f6cfa55887855e477fb9c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/445755 Auto-Submit: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
30b240b102
commit
0aeda5afe5
|
|
@ -21,7 +21,6 @@ type symNameFn func(s loader.Sym) string
|
|||
// ErrorReporter is used to make error reporting thread safe.
|
||||
type ErrorReporter struct {
|
||||
loader.ErrorReporter
|
||||
unresOnce sync.Once
|
||||
unresSyms map[unresolvedSymKey]bool
|
||||
unresMutex sync.Mutex
|
||||
SymName symNameFn
|
||||
|
|
@ -29,11 +28,13 @@ type ErrorReporter struct {
|
|||
|
||||
// errorUnresolved prints unresolved symbol error for rs that is referenced from s.
|
||||
func (reporter *ErrorReporter) errorUnresolved(ldr *loader.Loader, s, rs loader.Sym) {
|
||||
reporter.unresOnce.Do(func() { reporter.unresSyms = make(map[unresolvedSymKey]bool) })
|
||||
|
||||
k := unresolvedSymKey{from: s, to: rs}
|
||||
reporter.unresMutex.Lock()
|
||||
defer reporter.unresMutex.Unlock()
|
||||
|
||||
if reporter.unresSyms == nil {
|
||||
reporter.unresSyms = make(map[unresolvedSymKey]bool)
|
||||
}
|
||||
k := unresolvedSymKey{from: s, to: rs}
|
||||
if !reporter.unresSyms[k] {
|
||||
reporter.unresSyms[k] = true
|
||||
name := ldr.SymName(rs)
|
||||
|
|
|
|||
Loading…
Reference in New Issue