mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
cd589c8a73
commit
d32b4798f8
4 changed files with 246 additions and 6 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue