diff options
author | Russ Cox <rsc@golang.org> | 2015-03-20 00:06:10 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2015-03-20 20:05:37 +0000 |
commit | 4224d81fae7bfce98629894d14f4644018037cfb (patch) | |
tree | a69bfb0356406df650405a15ceee342f33313549 /src/runtime/error.go | |
parent | b115c35ee337ac6026539802d2ff085949dd1919 (diff) | |
download | go-4224d81fae7bfce98629894d14f4644018037cfb.tar.gz go-4224d81fae7bfce98629894d14f4644018037cfb.zip |
cmd/internal/gc: inline x := y.(*T) and x, ok := y.(*T)
These can be implemented with just a compare and a move instruction.
Do so, avoiding the overhead of a call into the runtime.
These assertions are a significant cost in Go code that uses interface{}
as a safe alternative to C's void* (or unsafe.Pointer), such as the
current version of the Go compiler.
*T here includes pointer to T but also any Go type represented as
a single pointer (chan, func, map). It does not include [1]*T or struct{*int}.
That requires more work in other parts of the compiler; there is a TODO.
Change-Id: I7ff681c20d2c3eb6ad11dd7b3a37b1f3dda23965
Reviewed-on: https://go-review.googlesource.com/7862
Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/runtime/error.go')
-rw-r--r-- | src/runtime/error.go | 19 |
1 files changed, 0 insertions, 19 deletions
diff --git a/src/runtime/error.go b/src/runtime/error.go index d8af4f156d..4280306ac5 100644 --- a/src/runtime/error.go +++ b/src/runtime/error.go @@ -43,25 +43,6 @@ func (e *TypeAssertionError) Error() string { ": missing method " + e.missingMethod } -// For calling from C. -func newTypeAssertionError(ps1, ps2, ps3 *string, pmeth *string, ret *interface{}) { - var s1, s2, s3, meth string - - if ps1 != nil { - s1 = *ps1 - } - if ps2 != nil { - s2 = *ps2 - } - if ps3 != nil { - s3 = *ps3 - } - if pmeth != nil { - meth = *pmeth - } - *ret = &TypeAssertionError{s1, s2, s3, meth} -} - // An errorString represents a runtime error described by a single string. type errorString string |