Skip to content

Commit 55a06f7

Browse files
apocelipesgopherbot
authored andcommitted
reflect: remove redundent ifaceIndir
Use abi.(*Type).IfaceIndir instead. Change-Id: I31197cbf0edaf53bbb0455fa76d2a4a2ab40b420 GitHub-Last-Rev: 2659b69 GitHub-Pull-Request: #67227 Reviewed-on: https://go-review.googlesource.com/c/go/+/583755 Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Keith Randall <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent c637d4b commit 55a06f7

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

src/reflect/abi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func (a *abiSeq) addRcvr(rcvr *abi.Type) (*abiStep, bool) {
166166
// The receiver is always one word.
167167
a.valueStart = append(a.valueStart, len(a.steps))
168168
var ok, ptr bool
169-
if ifaceIndir(rcvr) || rcvr.Pointers() {
169+
if rcvr.IfaceIndir() || rcvr.Pointers() {
170170
ok = a.assignIntN(0, goarch.PtrSize, 1, 0b1)
171171
ptr = true
172172
} else {

src/reflect/type.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,7 +2606,7 @@ func StructOf(fields []StructField) Type {
26062606
}
26072607

26082608
switch {
2609-
case len(fs) == 1 && !ifaceIndir(fs[0].Typ):
2609+
case len(fs) == 1 && !fs[0].Typ.IfaceIndir():
26102610
// structs of 1 direct iface type can be direct
26112611
typ.Kind_ |= abi.KindDirectIface
26122612
default:
@@ -2801,7 +2801,7 @@ func ArrayOf(length int, elem Type) Type {
28012801
}
28022802

28032803
switch {
2804-
case length == 1 && !ifaceIndir(typ):
2804+
case length == 1 && !typ.IfaceIndir():
28052805
// array of 1 direct iface type can be direct
28062806
array.Kind_ |= abi.KindDirectIface
28072807
default:
@@ -2903,11 +2903,6 @@ func funcLayout(t *funcType, rcvr *abi.Type) (frametype *abi.Type, framePool *sy
29032903
return lt.t, lt.framePool, lt.abid
29042904
}
29052905

2906-
// ifaceIndir reports whether t is stored indirectly in an interface value.
2907-
func ifaceIndir(t *abi.Type) bool {
2908-
return t.Kind_&abi.KindDirectIface == 0
2909-
}
2910-
29112906
// Note: this type must agree with runtime.bitvector.
29122907
type bitVector struct {
29132908
n uint32 // number of bits

src/reflect/value.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ func (v Value) call(op string, in []Value) []Value {
624624
}
625625

626626
// Handle pointers passed in registers.
627-
if !ifaceIndir(tv) {
627+
if !tv.IfaceIndir() {
628628
// Pointer-valued data gets put directly
629629
// into v.ptr.
630630
if steps[0].kind != abiStepPointer {
@@ -714,7 +714,7 @@ func callReflect(ctxt *makeFuncImpl, frame unsafe.Pointer, retValid *bool, regs
714714
v := Value{typ, nil, flag(typ.Kind())}
715715
steps := abid.call.stepsForValue(i)
716716
if st := steps[0]; st.kind == abiStepStack {
717-
if ifaceIndir(typ) {
717+
if typ.IfaceIndir() {
718718
// value cannot be inlined in interface data.
719719
// Must make a copy, because f might keep a reference to it,
720720
// and we cannot let f keep a reference to the stack frame
@@ -728,7 +728,7 @@ func callReflect(ctxt *makeFuncImpl, frame unsafe.Pointer, retValid *bool, regs
728728
v.ptr = *(*unsafe.Pointer)(add(ptr, st.stkOff, "1-ptr"))
729729
}
730730
} else {
731-
if ifaceIndir(typ) {
731+
if typ.IfaceIndir() {
732732
// All that's left is values passed in registers that we need to
733733
// create space for the values.
734734
v.flag |= flagIndir
@@ -914,7 +914,7 @@ func storeRcvr(v Value, p unsafe.Pointer) {
914914
// the interface data word becomes the receiver word
915915
iface := (*nonEmptyInterface)(v.ptr)
916916
*(*unsafe.Pointer)(p) = iface.word
917-
} else if v.flag&flagIndir != 0 && !ifaceIndir(t) {
917+
} else if v.flag&flagIndir != 0 && !t.IfaceIndir() {
918918
*(*unsafe.Pointer)(p) = *(*unsafe.Pointer)(v.ptr)
919919
} else {
920920
*(*unsafe.Pointer)(p) = v.ptr
@@ -1232,7 +1232,7 @@ func (v Value) Elem() Value {
12321232
case Pointer:
12331233
ptr := v.ptr
12341234
if v.flag&flagIndir != 0 {
1235-
if ifaceIndir(v.typ()) {
1235+
if v.typ().IfaceIndir() {
12361236
// This is a pointer to a not-in-heap object. ptr points to a uintptr
12371237
// in the heap. That uintptr is the address of a not-in-heap object.
12381238
// In general, pointers to not-in-heap objects can be total junk.
@@ -2258,7 +2258,7 @@ func (v Value) recv(nb bool) (val Value, ok bool) {
22582258
t := tt.Elem
22592259
val = Value{t, nil, flag(t.Kind())}
22602260
var p unsafe.Pointer
2261-
if ifaceIndir(t) {
2261+
if t.IfaceIndir() {
22622262
p = unsafe_New(t)
22632263
val.ptr = p
22642264
val.flag |= flagIndir
@@ -3297,7 +3297,7 @@ func New(typ Type) Value {
32973297
}
32983298
t := &typ.(*rtype).t
32993299
pt := ptrTo(t)
3300-
if ifaceIndir(pt) {
3300+
if pt.IfaceIndir() {
33013301
// This is a pointer to a not-in-heap type.
33023302
panic("reflect: New of type that may not be allocated in heap (possibly undefined cgo C type)")
33033303
}

0 commit comments

Comments
 (0)