forked from mirror/go-json
Refactor
This commit is contained in:
parent
34b662b98e
commit
efcf2dec06
13
encode_vm.go
13
encode_vm.go
|
@ -152,20 +152,15 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, recursiveLevel int, seenPtr map
|
||||||
curlen := uintptr(len(ctx.ptrs))
|
curlen := uintptr(len(ctx.ptrs))
|
||||||
offsetNum := ptrOffset / uintptrSize
|
offsetNum := ptrOffset / uintptrSize
|
||||||
oldOffset := ptrOffset
|
oldOffset := ptrOffset
|
||||||
ptrOffset = ptrOffset + totalLength*uintptrSize // curlen * uintptrSize
|
ptrOffset += totalLength * uintptrSize
|
||||||
}
|
|
||||||
newLen := offsetNum + totalLength + nextTotalLength
|
newLen := offsetNum + totalLength + nextTotalLength
|
||||||
if curlen < newLen {
|
if curlen < newLen {
|
||||||
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
|
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
|
||||||
store(ctx.ptr()+ptrOffset, 0, uintptr(header.ptr))
|
|
||||||
} else {
|
|
||||||
store(ctx.ptr()+ptrOffset, 0, uintptr(header.ptr))
|
|
||||||
}
|
}
|
||||||
ctxptr = ctx.ptr() + ptrOffset // assign new ctxptr
|
ctxptr = ctx.ptr() + ptrOffset // assign new ctxptr
|
||||||
if load(ctxptr, 0) != uintptr(header.ptr) {
|
|
||||||
panic(nil)
|
store(ctxptr, 0, uintptr(header.ptr))
|
||||||
}
|
|
||||||
// save current ctxptr
|
|
||||||
store(ctxptr, lastCode.idx, oldOffset)
|
store(ctxptr, lastCode.idx, oldOffset)
|
||||||
|
|
||||||
// link lastCode ( opInterfaceEnd ) => code.next
|
// link lastCode ( opInterfaceEnd ) => code.next
|
||||||
|
|
Loading…
Reference in New Issue