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/cgocall.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/cgocall.go')
-rw-r--r-- | src/runtime/cgocall.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/runtime/cgocall.go b/src/runtime/cgocall.go index 85b6c8289a..123607247a 100644 --- a/src/runtime/cgocall.go +++ b/src/runtime/cgocall.go @@ -460,7 +460,7 @@ const cgoResultFail = "cgo result has Go pointer" // depending on indir. The top parameter is whether we are at the top // level, where Go pointers are allowed. func cgoCheckArg(t *_type, p unsafe.Pointer, indir, top bool, msg string) { - if t.kind&kindNoPointers != 0 { + if t.ptrdata == 0 { // If the type has no pointers there is nothing to do. return } @@ -523,7 +523,7 @@ func cgoCheckArg(t *_type, p unsafe.Pointer, indir, top bool, msg string) { if !top { panic(errorString(msg)) } - if st.elem.kind&kindNoPointers != 0 { + if st.elem.ptrdata == 0 { return } for i := 0; i < s.cap; i++ { |