mirror of https://github.com/goccy/go-json.git
Fix resolve conflict to #55
This commit is contained in:
parent
bfa3640e2b
commit
96528cbae4
10
encode_vm.go
10
encode_vm.go
|
@ -187,8 +187,8 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, code *opcode) error {
|
||||||
code = code.next
|
code = code.next
|
||||||
case opBytesIndent:
|
case opBytesIndent:
|
||||||
ptr := load(ctxptr, code.idx)
|
ptr := load(ctxptr, code.idx)
|
||||||
header := (*reflect.SliceHeader)(unsafe.Pointer(ptr))
|
header := (*sliceHeader)(unsafe.Pointer(&ptr))
|
||||||
if ptr == 0 || header.Data == 0 {
|
if ptr == 0 || uintptr(header.data) == 0 {
|
||||||
e.encodeNull()
|
e.encodeNull()
|
||||||
} else {
|
} else {
|
||||||
e.encodeByteSlice(e.ptrToBytes(ptr))
|
e.encodeByteSlice(e.ptrToBytes(ptr))
|
||||||
|
@ -205,7 +205,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, code *opcode) error {
|
||||||
}
|
}
|
||||||
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{
|
||||||
typ: code.typ,
|
typ: code.typ,
|
||||||
ptr: unsafe.Pointer(ptr),
|
ptr: *(*unsafe.Pointer)(unsafe.Pointer(&ptr)),
|
||||||
}))
|
}))
|
||||||
if _, exists := seenPtr[ptr]; exists {
|
if _, exists := seenPtr[ptr]; exists {
|
||||||
return &UnsupportedValueError{
|
return &UnsupportedValueError{
|
||||||
|
@ -407,7 +407,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, code *opcode) error {
|
||||||
ptr := load(ctxptr, code.idx)
|
ptr := load(ctxptr, code.idx)
|
||||||
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{
|
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{
|
||||||
typ: code.typ,
|
typ: code.typ,
|
||||||
ptr: unsafe.Pointer(ptr),
|
ptr: *(*unsafe.Pointer)(unsafe.Pointer(&ptr)),
|
||||||
}))
|
}))
|
||||||
b, err := v.(Marshaler).MarshalJSON()
|
b, err := v.(Marshaler).MarshalJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -472,7 +472,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, code *opcode) error {
|
||||||
case opMarshalTextIndent:
|
case opMarshalTextIndent:
|
||||||
ptr := load(ctxptr, code.idx)
|
ptr := load(ctxptr, code.idx)
|
||||||
isPtr := code.typ.Kind() == reflect.Ptr
|
isPtr := code.typ.Kind() == reflect.Ptr
|
||||||
p := unsafe.Pointer(ptr)
|
p := *(*unsafe.Pointer)(unsafe.Pointer(&ptr))
|
||||||
if p == nil {
|
if p == nil {
|
||||||
e.encodeNull()
|
e.encodeNull()
|
||||||
e.encodeBytes([]byte{',', '\n'})
|
e.encodeBytes([]byte{',', '\n'})
|
||||||
|
|
Loading…
Reference in New Issue