forked from mirror/go-json
refactor: to check for IsDirectedNil only if ifacePtr == nil
This commit is contained in:
parent
c8d6da88dd
commit
884b8dbf9a
|
@ -194,12 +194,14 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
typ = iface.typ
|
typ = iface.typ
|
||||||
}
|
}
|
||||||
|
if ifacePtr == nil {
|
||||||
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
|
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
|
||||||
if ifacePtr == nil && !isDirectedNil {
|
if !isDirectedNil {
|
||||||
b = appendNullComma(ctx, b)
|
b = appendNullComma(ctx, b)
|
||||||
code = code.Next
|
code = code.Next
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ctx.KeepRefs = append(ctx.KeepRefs, up)
|
ctx.KeepRefs = append(ctx.KeepRefs, up)
|
||||||
ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ)))
|
ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -194,12 +194,14 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
typ = iface.typ
|
typ = iface.typ
|
||||||
}
|
}
|
||||||
|
if ifacePtr == nil {
|
||||||
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
|
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
|
||||||
if ifacePtr == nil && !isDirectedNil {
|
if !isDirectedNil {
|
||||||
b = appendNullComma(ctx, b)
|
b = appendNullComma(ctx, b)
|
||||||
code = code.Next
|
code = code.Next
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ctx.KeepRefs = append(ctx.KeepRefs, up)
|
ctx.KeepRefs = append(ctx.KeepRefs, up)
|
||||||
ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ)))
|
ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -194,12 +194,14 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
typ = iface.typ
|
typ = iface.typ
|
||||||
}
|
}
|
||||||
|
if ifacePtr == nil {
|
||||||
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
|
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
|
||||||
if ifacePtr == nil && !isDirectedNil {
|
if !isDirectedNil {
|
||||||
b = appendNullComma(ctx, b)
|
b = appendNullComma(ctx, b)
|
||||||
code = code.Next
|
code = code.Next
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ctx.KeepRefs = append(ctx.KeepRefs, up)
|
ctx.KeepRefs = append(ctx.KeepRefs, up)
|
||||||
ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ)))
|
ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -194,12 +194,14 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
typ = iface.typ
|
typ = iface.typ
|
||||||
}
|
}
|
||||||
|
if ifacePtr == nil {
|
||||||
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
|
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
|
||||||
if ifacePtr == nil && !isDirectedNil {
|
if !isDirectedNil {
|
||||||
b = appendNullComma(ctx, b)
|
b = appendNullComma(ctx, b)
|
||||||
code = code.Next
|
code = code.Next
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ctx.KeepRefs = append(ctx.KeepRefs, up)
|
ctx.KeepRefs = append(ctx.KeepRefs, up)
|
||||||
ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ)))
|
ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -194,12 +194,14 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
typ = iface.typ
|
typ = iface.typ
|
||||||
}
|
}
|
||||||
|
if ifacePtr == nil {
|
||||||
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
|
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
|
||||||
if ifacePtr == nil && !isDirectedNil {
|
if !isDirectedNil {
|
||||||
b = appendNullComma(ctx, b)
|
b = appendNullComma(ctx, b)
|
||||||
code = code.Next
|
code = code.Next
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ctx.KeepRefs = append(ctx.KeepRefs, up)
|
ctx.KeepRefs = append(ctx.KeepRefs, up)
|
||||||
ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ)))
|
ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue