Skip to content

Commit

Permalink
refactor: to check for IsDirectedNil only if ifacePtr == nil
Browse files Browse the repository at this point in the history
  • Loading branch information
orisano committed Jul 3, 2022
1 parent c8d6da8 commit 884b8db
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 25 deletions.
12 changes: 7 additions & 5 deletions internal/cmd/generator/vm.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
ifacePtr = iface.ptr
typ = iface.typ
}
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
if ifacePtr == nil && !isDirectedNil {
b = appendNullComma(ctx, b)
code = code.Next
break
if ifacePtr == nil {
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
if !isDirectedNil {
b = appendNullComma(ctx, b)
code = code.Next
break
}
}
ctx.KeepRefs = append(ctx.KeepRefs, up)
ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ)))
Expand Down
12 changes: 7 additions & 5 deletions internal/encoder/vm/vm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions internal/encoder/vm_color/vm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions internal/encoder/vm_color_indent/vm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions internal/encoder/vm_indent/vm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 884b8db

Please sign in to comment.