diff options
author | Keith Randall <khr@google.com> | 2019-03-25 12:34:27 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2019-03-25 20:46:35 +0000 |
commit | db16de920370892b0241d3fa0617dddff2417a4d (patch) | |
tree | 3a85666fe3b1d1d16dc457ae286e4f133e0c1ce0 /src/runtime/map.go | |
parent | 501632339f36e7e836ec94958351cee51ee76461 (diff) | |
download | go-db16de920370892b0241d3fa0617dddff2417a4d.tar.gz go-db16de920370892b0241d3fa0617dddff2417a4d.zip |
runtime: remove kindNoPointers
We already have the ptrdata field in a type, which encodes exactly
the same information that kindNoPointers does.
My problem with kindNoPointers is that it often leads to
double-negative code like:
t.kind & kindNoPointers != 0
Much clearer is:
t.ptrdata == 0
Update #27167
Change-Id: I92307d7f018a6bbe3daca4a4abb4225e359349b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/169157
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@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 9c25b63348..0ebbf2ae76 100644 --- a/src/runtime/map.go +++ b/src/runtime/map.go @@ -264,7 +264,7 @@ func (h *hmap) newoverflow(t *maptype, b *bmap) *bmap { ovf = (*bmap)(newobject(t.bucket)) } h.incrnoverflow() - if t.bucket.kind&kindNoPointers != 0 { + if t.bucket.ptrdata == 0 { h.createOverflow() *h.extra.overflow = append(*h.extra.overflow, ovf) } @@ -368,7 +368,7 @@ func makeBucketArray(t *maptype, b uint8, dirtyalloc unsafe.Pointer) (buckets un // but may not be empty. buckets = dirtyalloc size := t.bucket.size * nbuckets - if t.bucket.kind&kindNoPointers == 0 { + if t.bucket.ptrdata != 0 { memclrHasPointers(buckets, size) } else { memclrNoHeapPointers(buckets, size) @@ -742,13 +742,13 @@ search: // Only clear key if there are pointers in it. if t.indirectkey() { *(*unsafe.Pointer)(k) = nil - } else if t.key.kind&kindNoPointers == 0 { + } else if t.key.ptrdata != 0 { memclrHasPointers(k, t.key.size) } v := add(unsafe.Pointer(b), dataOffset+bucketCnt*uintptr(t.keysize)+i*uintptr(t.valuesize)) if t.indirectvalue() { *(*unsafe.Pointer)(v) = nil - } else if t.elem.kind&kindNoPointers == 0 { + } else if t.elem.ptrdata != 0 { memclrHasPointers(v, t.elem.size) } else { memclrNoHeapPointers(v, t.elem.size) @@ -820,7 +820,7 @@ func mapiterinit(t *maptype, h *hmap, it *hiter) { // grab snapshot of bucket state it.B = h.B it.buckets = h.buckets - if t.bucket.kind&kindNoPointers != 0 { + if t.bucket.ptrdata == 0 { // Allocate the current slice and remember pointers to both current and old. // This preserves all relevant overflow buckets alive even if // the table grows and/or overflow buckets are added to the table @@ -1232,7 +1232,7 @@ func evacuate(t *maptype, h *hmap, oldbucket uintptr) { } } // Unlink the overflow buckets & clear key/value to help GC. - if h.flags&oldIterator == 0 && t.bucket.kind&kindNoPointers == 0 { + if h.flags&oldIterator == 0 && t.bucket.ptrdata != 0 { b := add(h.oldbuckets, oldbucket*uintptr(t.bucketsize)) // Preserve b.tophash because the evacuation // state is maintained there. |