Commit 1d4bfb3e authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/gc: don't call memequal twice in generated type.eq routines

The first call is pointless. It appears to simply be a mistake.

benchmark                  old ns/op     new ns/op     delta
BenchmarkComplexAlgMap     90.7          76.1          -16.10%

Change-Id: Id0194c9f09cea8b68f17b2ac751a8e3240e47f19
Reviewed-on: https://go-review.googlesource.com/5284Reviewed-by: 's avatarKeith Randall <khr@golang.org>
parent 9c4aade5
...@@ -2848,7 +2848,6 @@ func eqmem(p *Node, q *Node, field *Node, size int64) *Node { ...@@ -2848,7 +2848,6 @@ func eqmem(p *Node, q *Node, field *Node, size int64) *Node {
} }
nif := Nod(OIF, nil, nil) nif := Nod(OIF, nil, nil)
nif.Ninit = list(nif.Ninit, call)
nif.Ntest = Nod(ONOT, call, nil) nif.Ntest = Nod(ONOT, call, nil)
r := Nod(ORETURN, nil, nil) r := Nod(ORETURN, nil, nil)
r.List = list(r.List, Nodbool(false)) r.List = list(r.List, Nodbool(false))
......
...@@ -307,3 +307,22 @@ func BenchmarkSmallKeyMap(b *testing.B) { ...@@ -307,3 +307,22 @@ func BenchmarkSmallKeyMap(b *testing.B) {
_ = m[5] _ = m[5]
} }
} }
type ComplexAlgKey struct {
a, b, c int64
_ int
d int32
_ int
e string
_ int
f, g, h int64
}
func BenchmarkComplexAlgMap(b *testing.B) {
m := make(map[ComplexAlgKey]bool)
var k ComplexAlgKey
m[k] = true
for i := 0; i < b.N; i++ {
_ = m[k]
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment