1
0
mirror of https://github.com/golang/go synced 2024-11-19 16:14:49 -07:00

runtime: only clear key string's pointer in mapdelete_faststr

Change-Id: I0360d294868ec4423e4ae036009fac4e72425c9c
Reviewed-on: https://go-review.googlesource.com/59152
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2017-08-26 06:55:34 -07:00
parent 8adaf68570
commit dc10aeeff8

View File

@ -754,7 +754,8 @@ search:
if k.str != key.str && !memequal(k.str, key.str, uintptr(key.len)) { if k.str != key.str && !memequal(k.str, key.str, uintptr(key.len)) {
continue continue
} }
*(*string)(kptr) = "" // Clear key's pointer.
k.str = nil
// Only clear value if there are pointers in it. // Only clear value if there are pointers in it.
if t.elem.kind&kindNoPointers == 0 { if t.elem.kind&kindNoPointers == 0 {
v := add(unsafe.Pointer(b), dataOffset+bucketCnt*2*sys.PtrSize+i*uintptr(t.valuesize)) v := add(unsafe.Pointer(b), dataOffset+bucketCnt*2*sys.PtrSize+i*uintptr(t.valuesize))