aboutsummaryrefslogtreecommitdiff
path: root/test/map1.go
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/map1.go
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/map1.go')
-rw-r--r--test/map1.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/map1.go b/test/map1.go
index 923e27e672..6af10565cd 100644
--- a/test/map1.go
+++ b/test/map1.go
@@ -31,11 +31,11 @@ var (
_ map[string]v
_ map[chan int]v
_ map[*int]v
+ _ map[struct{}]v
+ _ map[[10]int]v
// invalid
- _ map[struct{}]v // ERROR "invalid map key"
_ map[[]int]v // ERROR "invalid map key"
- _ map[[10]int]v // ERROR "invalid map key"
_ map[func()]v // ERROR "invalid map key"
_ map[map[int]int]v // ERROR "invalid map key"
)