]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: don't call memequal twice in generated type.eq routines
authorJosh Bleecher Snyder <josharian@gmail.com>
Thu, 19 Feb 2015 00:27:48 +0000 (16:27 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Thu, 26 Feb 2015 00:34:29 +0000 (00:34 +0000)
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/5284
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/internal/gc/subr.go
src/runtime/mapspeed_test.go

index 9dc573e79528cbb174d73499bfc91f5e14ebcc9b..b970f1d21a26d38742948728853129b1fc5934df 100644 (file)
@@ -2848,7 +2848,6 @@ func eqmem(p *Node, q *Node, field *Node, size int64) *Node {
        }
 
        nif := Nod(OIF, nil, nil)
-       nif.Ninit = list(nif.Ninit, call)
        nif.Ntest = Nod(ONOT, call, nil)
        r := Nod(ORETURN, nil, nil)
        r.List = list(r.List, Nodbool(false))
index b036d2a3ab105ff6db5134016b8fab5e1aaf0c91..ac93119d77d8b7c94d9494ab0d848f63ae168032 100644 (file)
@@ -307,3 +307,22 @@ func BenchmarkSmallKeyMap(b *testing.B) {
                _ = 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]
+       }
+}