forked from mirror/go-json
Reset seenPtr
This commit is contained in:
parent
70f8f01ef3
commit
572d4842a5
|
@ -164,6 +164,7 @@ func (e *Encoder) encode(v interface{}) error {
|
||||||
}
|
}
|
||||||
ctx := codeSet.ctx.Get().(*encodeRuntimeContext)
|
ctx := codeSet.ctx.Get().(*encodeRuntimeContext)
|
||||||
p := uintptr(header.ptr)
|
p := uintptr(header.ptr)
|
||||||
|
ctx.reset()
|
||||||
ctx.init(p)
|
ctx.init(p)
|
||||||
err := e.run(ctx, code)
|
err := e.run(ctx, code)
|
||||||
if e.enabledIndent {
|
if e.enabledIndent {
|
||||||
|
@ -218,6 +219,7 @@ func (e *Encoder) encode(v interface{}) error {
|
||||||
cachedOpcode.set(typeptr, codeSet)
|
cachedOpcode.set(typeptr, codeSet)
|
||||||
p := uintptr(header.ptr)
|
p := uintptr(header.ptr)
|
||||||
ctx := codeSet.ctx.Get().(*encodeRuntimeContext)
|
ctx := codeSet.ctx.Get().(*encodeRuntimeContext)
|
||||||
|
ctx.reset()
|
||||||
ctx.init(p)
|
ctx.init(p)
|
||||||
if e.enabledIndent {
|
if e.enabledIndent {
|
||||||
err := e.run(ctx, codeIndent)
|
err := e.run(ctx, codeIndent)
|
||||||
|
|
|
@ -63,6 +63,10 @@ type encodeRuntimeContext struct {
|
||||||
seenPtr map[uintptr]struct{}
|
seenPtr map[uintptr]struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *encodeRuntimeContext) reset() {
|
||||||
|
c.seenPtr = map[uintptr]struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *encodeRuntimeContext) init(p uintptr) {
|
func (c *encodeRuntimeContext) init(p uintptr) {
|
||||||
c.ptrs[0] = p
|
c.ptrs[0] = p
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue