diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2015-10-21 12:12:25 -0700 |
|---|---|---|
| committer | Matthew Dempsky <mdempsky@google.com> | 2015-10-21 23:08:22 +0000 |
| commit | 84afa1be76f89a602c1aef73603175e644f1dc2f (patch) | |
| tree | 090b42d927619808e5c4bb61461dfc20b5857463 /src/runtime/alg.go | |
| parent | 03b0065204df9cd141919890b23de6291ab52885 (diff) | |
| download | go-84afa1be76f89a602c1aef73603175e644f1dc2f.tar.xz | |
runtime: make iface/eface handling more type safe
Change compiler-invoked interface functions to directly take
iface/eface parameters instead of fInterface/interface{} to avoid
needing to always convert.
For the handful of functions that legitimately need to take an
interface{} parameter, add efaceOf to type-safely convert *interface{}
to *eface.
Change-Id: I8928761a12fd3c771394f36adf93d3006a9fcf39
Reviewed-on: https://go-review.googlesource.com/16166
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/alg.go')
| -rw-r--r-- | src/runtime/alg.go | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/runtime/alg.go b/src/runtime/alg.go index bb2f2b8ddb..95173495c3 100644 --- a/src/runtime/alg.go +++ b/src/runtime/alg.go @@ -226,18 +226,12 @@ func strequal(p, q unsafe.Pointer) bool { return *(*string)(p) == *(*string)(q) } func interequal(p, q unsafe.Pointer) bool { - return ifaceeq(*(*interface { - f() - })(p), *(*interface { - f() - })(q)) + return ifaceeq(*(*iface)(p), *(*iface)(q)) } func nilinterequal(p, q unsafe.Pointer) bool { - return efaceeq(*(*interface{})(p), *(*interface{})(q)) + return efaceeq(*(*eface)(p), *(*eface)(q)) } -func efaceeq(p, q interface{}) bool { - x := (*eface)(unsafe.Pointer(&p)) - y := (*eface)(unsafe.Pointer(&q)) +func efaceeq(x, y eface) bool { t := x._type if t != y._type { return false @@ -254,11 +248,7 @@ func efaceeq(p, q interface{}) bool { } return eq(x.data, y.data) } -func ifaceeq(p, q interface { - f() -}) bool { - x := (*iface)(unsafe.Pointer(&p)) - y := (*iface)(unsafe.Pointer(&q)) +func ifaceeq(x, y iface) bool { xtab := x.tab if xtab != y.tab { return false |
