mirror of
https://github.com/golang/go
synced 2024-11-07 14:36:17 -07:00
db16de9203
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>
44 lines
742 B
Go
44 lines
742 B
Go
// Copyright 2014 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package runtime
|
|
|
|
const (
|
|
kindBool = 1 + iota
|
|
kindInt
|
|
kindInt8
|
|
kindInt16
|
|
kindInt32
|
|
kindInt64
|
|
kindUint
|
|
kindUint8
|
|
kindUint16
|
|
kindUint32
|
|
kindUint64
|
|
kindUintptr
|
|
kindFloat32
|
|
kindFloat64
|
|
kindComplex64
|
|
kindComplex128
|
|
kindArray
|
|
kindChan
|
|
kindFunc
|
|
kindInterface
|
|
kindMap
|
|
kindPtr
|
|
kindSlice
|
|
kindString
|
|
kindStruct
|
|
kindUnsafePointer
|
|
|
|
kindDirectIface = 1 << 5
|
|
kindGCProg = 1 << 6
|
|
kindMask = (1 << 5) - 1
|
|
)
|
|
|
|
// isDirectIface reports whether t is stored directly in an interface value.
|
|
func isDirectIface(t *_type) bool {
|
|
return t.kind&kindDirectIface != 0
|
|
}
|