diff options
| author | cuiweixie <cuiweixie@gmail.com> | 2023-06-09 22:59:48 +0800 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2023-08-09 16:41:16 +0000 |
| commit | d32b4798f844882d20920b7e75e9a889d3d0036c (patch) | |
| tree | 7b2c0c4c017ae1e36fa9ee2fb713d4fa19608213 /src/runtime/map.go | |
| parent | cd589c8a73415afbf94a8976f20cbed9d4061ba6 (diff) | |
| download | go-d32b4798f844882d20920b7e75e9a889d3d0036c.tar.xz | |
runtime: improve performance of empty map with interface key type
name old time/op new time/op delta
MegEmptyMapWithInterfaceKey-10 15.5µs ± 0% 0.0µs ± 0% -99.97% (p=0.000 n=20+16)
name old alloc/op new alloc/op delta
MegEmptyMapWithInterfaceKey-10 0.00B 0.00B ~ (all equal)
name old allocs/op new allocs/op delta
MegEmptyMapWithInterfaceKey-10 0.00 0.00 ~ (all equal)
Change-Id: I46248223100e98b7877464da640075d272c14802
Reviewed-on: https://go-review.googlesource.com/c/go/+/502075
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/map.go')
| -rw-r--r-- | src/runtime/map.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/runtime/map.go b/src/runtime/map.go index 7b954759f1..5d4e470b9e 100644 --- a/src/runtime/map.go +++ b/src/runtime/map.go @@ -407,8 +407,8 @@ func mapaccess1(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer { asanread(key, t.Key.Size_) } if h == nil || h.count == 0 { - if t.HashMightPanic() { - t.Hasher(key, 0) // see issue 23734 + if err := mapKeyError(t, key); err != nil { + panic(err) // see issue 23734 } return unsafe.Pointer(&zeroVal[0]) } @@ -468,8 +468,8 @@ func mapaccess2(t *maptype, h *hmap, key unsafe.Pointer) (unsafe.Pointer, bool) asanread(key, t.Key.Size_) } if h == nil || h.count == 0 { - if t.HashMightPanic() { - t.Hasher(key, 0) // see issue 23734 + if err := mapKeyError(t, key); err != nil { + panic(err) // see issue 23734 } return unsafe.Pointer(&zeroVal[0]), false } @@ -707,8 +707,8 @@ func mapdelete(t *maptype, h *hmap, key unsafe.Pointer) { asanread(key, t.Key.Size_) } if h == nil || h.count == 0 { - if t.HashMightPanic() { - t.Hasher(key, 0) // see issue 23734 + if err := mapKeyError(t, key); err != nil { + panic(err) // see issue 23734 } return } |
