aboutsummaryrefslogtreecommitdiff
path: root/test/interface
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-12-12 22:22:09 -0500
committerRuss Cox <rsc@golang.org>2011-12-12 22:22:09 -0500
commit196b6630759c6f4125c22445dd5b6cfec5faf34b (patch)
tree43ae44cf228030c8358410af212994bca7f74e7f /test/interface
parent83f648c9625343045da1e6b4ecc3d207c84403b3 (diff)
downloadgo-196b6630759c6f4125c22445dd5b6cfec5faf34b.tar.gz
go-196b6630759c6f4125c22445dd5b6cfec5faf34b.zip
gc: implement == on structs and arrays
To allow these types as map keys, we must fill in equal and hash functions in their algorithm tables. Structs or arrays that are "just memory", like [2]int, can and do continue to use the AMEM algorithm. Structs or arrays that contain special values like strings or interface values use generated functions for both equal and hash. The runtime helper func runtime.equal(t, x, y) bool handles the general equality case for x == y and calls out to the equal implementation in the algorithm table. For short values (<= 4 struct fields or array elements), the sequence of elementwise comparisons is inlined instead of calling runtime.equal. R=ken, mpimenov CC=golang-dev https://golang.org/cl/5451105
Diffstat (limited to 'test/interface')
-rw-r--r--test/interface/noeq.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/interface/noeq.go b/test/interface/noeq.go
index be368218d7..3c2ea5975a 100644
--- a/test/interface/noeq.go
+++ b/test/interface/noeq.go
@@ -10,10 +10,10 @@ package main
func main() {
cmp(1)
-
+
var (
m map[int]int
- s struct{}
+ s struct{ x []int }
f func()
)
noCmp(m)