]> Cypherpunks repositories - gostls13.git/commit
cmd/internal/gc, runtime: speed up some cases of _, ok := i.(T)
authorJosh Bleecher Snyder <josharian@gmail.com>
Tue, 17 Mar 2015 22:14:31 +0000 (15:14 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Thu, 19 Mar 2015 16:20:32 +0000 (16:20 +0000)
commit25e793d7ea7519f407cb84c4cb3955f5b96d0fb5
tree4f50b12979c291ce192e8ce0a58e055496d7edf3
parent55b4516fd65b0e471556330a0d89af6b7e59ae93
cmd/internal/gc, runtime: speed up some cases of _, ok := i.(T)

Some type assertions of the form _, ok := i.(T) allow efficient inlining.
Such type assertions commonly show up in type switches.
For example, with this optimization, using 6g, the length of
encoding/binary's intDataSize function shrinks from 2224 to 1728 bytes (-22%).

benchmark                    old ns/op     new ns/op     delta
BenchmarkAssertI2E2Blank     4.67          0.82          -82.44%
BenchmarkAssertE2T2Blank     4.38          0.83          -81.05%
BenchmarkAssertE2E2Blank     3.88          0.83          -78.61%
BenchmarkAssertE2E2          14.2          14.4          +1.41%
BenchmarkAssertE2T2          10.3          10.4          +0.97%
BenchmarkAssertI2E2          13.4          13.3          -0.75%

Change-Id: Ie9798c3e85432bb8e0f2c723afc376e233639df7
Reviewed-on: https://go-review.googlesource.com/7697
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/internal/gc/walk.go
src/runtime/iface.go
src/runtime/iface_test.go