Skip to content

Commit 412b5e9

Browse files
committed
go/types/typeutil: make Hasher stateless
This CL makes Hasher an empty struct: consequently, Hashers are stateless and all are equivalent. Whatever optimization benefit Hasher had when it was introduced is no longer evident: the benchmark added in this CL went from 5.2ms (using the old hasher) to 3.3ms (without). It also simplifies the API and relaxes the concurrency constraints. Fixes golang/go#69407 Change-Id: Ic6fa54451bee20cba72cd7133cf9afd38e7c3ca8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/612496 Reviewed-by: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 6d4eee4 commit 412b5e9

File tree

3 files changed

+140
-152
lines changed

3 files changed

+140
-152
lines changed

go/ssa/interp/value.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ var (
9999
// hashType returns a hash for t such that
100100
// types.Identical(x, y) => hashType(x) == hashType(y).
101101
func hashType(t types.Type) int {
102-
mu.Lock()
103-
h := int(hasher.Hash(t))
104-
mu.Unlock()
105-
return h
102+
return int(hasher.Hash(t))
106103
}
107104

108105
// usesBuiltinMap returns true if the built-in hash function and

0 commit comments

Comments
 (0)