forked from mirror/go-json
Compare commits
1 Commits
master
...
feature/re
Author | SHA1 | Date |
---|---|---|
Masaaki Goshima | fbfaea2c88 |
59
encode_vm.go
59
encode_vm.go
|
@ -596,36 +596,36 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
}
|
||||
}
|
||||
case opStructFieldPtrHeadInt:
|
||||
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
|
||||
p := ptrToPtr(load(ctxptr, code.idx))
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, p)
|
||||
fallthrough
|
||||
case opStructFieldHeadInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
p := load(ctxptr, code.idx) + code.offset
|
||||
b = append(b, '{')
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
p := ptrToPtr(load(ctxptr, code.idx))
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, p)
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyInt:
|
||||
p := load(ctxptr, code.idx) + code.offset
|
||||
b = append(b, '{')
|
||||
u64 := ptrToUint64(ptr + code.offset)
|
||||
u64 := ptrToUint64(p)
|
||||
v := u64 & code.mask
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
|
@ -635,28 +635,25 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
|
|||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
p := ptrToPtr(load(ctxptr, code.idx))
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, p)
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagInt:
|
||||
p := load(ctxptr, code.idx) + code.offset
|
||||
b = append(b, '{')
|
||||
b = append(b, code.key...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadIntOnly, opStructFieldHeadIntOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
|
|
Loading…
Reference in New Issue