Add test cases for int type

This commit is contained in:
Masaaki Goshima 2021-01-14 00:02:58 +09:00
parent fd1085102c
commit 67a7ac450b
6 changed files with 2141 additions and 170 deletions

File diff suppressed because it is too large Load Diff

View File

@ -105,7 +105,17 @@ func (e *Encoder) convertHeadOnlyCode(c *opcode, isPtrHead bool) {
} }
c.op = opStructFieldHeadOnly c.op = opStructFieldHeadOnly
case opStructFieldHeadOmitEmpty: case opStructFieldHeadOmitEmpty:
return e.convertHeadOnlyCode(c.next, false)
if !strings.Contains(c.next.op.String(), "Only") {
return
}
c.op = opStructFieldHeadOmitEmptyOnly
case opStructFieldHeadStringTag:
e.convertHeadOnlyCode(c.next, false)
if !strings.Contains(c.next.op.String(), "Only") {
return
}
c.op = opStructFieldHeadStringTagOnly
case opStructFieldPtrHead: case opStructFieldPtrHead:
} }

View File

@ -615,7 +615,30 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
code = code.next code = code.next
store(ctxptr, code.idx, p) store(ctxptr, code.idx, p)
} }
case opStructFieldHeadOnly: case opStructFieldPtrHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
case opStructFieldHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
b = append(b, '{')
p := ptr + code.offset
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
code = code.nextField
} else {
b = append(b, code.key...)
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
b = append(b, '{') b = append(b, '{')
if !code.anonymousKey { if !code.anonymousKey {
@ -624,6 +647,19 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
p := ptr + code.offset p := ptr + code.offset
code = code.next code = code.next
store(ctxptr, code.idx, p) store(ctxptr, code.idx, p)
case opStructFieldHeadOmitEmptyOnly:
ptr := load(ctxptr, code.idx)
b = append(b, '{')
if !code.anonymousKey {
if ptr != 0 {
b = append(b, code.key...)
p := ptr + code.offset
code = code.next
store(ctxptr, code.idx, p)
} else {
code = code.nextField
}
}
case opStructFieldAnonymousHead: case opStructFieldAnonymousHead:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
if ptr == 0 { if ptr == 0 {
@ -632,6 +668,26 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
code = code.next code = code.next
store(ctxptr, code.idx, ptr) store(ctxptr, code.idx, ptr)
} }
case opStructFieldPtrAnonymousHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
case opStructFieldAnonymousHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
p := ptr + code.offset
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
code = code.nextField
} else {
b = append(b, code.key...)
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldPtrHeadInt: case opStructFieldPtrHeadInt:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough fallthrough
@ -775,7 +831,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
b = append(b, code.key...) b = append(b, code.key...)
p = e.ptrToPtr(p) p = e.ptrToPtr(p)
if p == 0 { if p == 0 {
b = append(b, `""`...) b = encodeNull(b)
} else { } else {
b = append(b, '"') b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset))) b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
@ -839,7 +895,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
b = append(b, '{') b = append(b, '{')
b = append(b, code.key...) b = append(b, code.key...)
if p == 0 { if p == 0 {
b = append(b, `""`...) b = encodeNull(b)
} else { } else {
b = append(b, '"') b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset))) b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
@ -930,6 +986,33 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
} }
case opStructFieldPtrAnonymousHeadOmitEmptyIntOnly, opStructFieldAnonymousHeadOmitEmptyIntOnly:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToInt(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.key...)
b = appendInt(b, int64(v))
b = encodeComma(b)
code = code.next
}
}
case opStructFieldPtrAnonymousHeadStringTagIntOnly, opStructFieldAnonymousHeadStringTagIntOnly:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
b = append(b, code.key...)
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadIntPtr: case opStructFieldPtrAnonymousHeadIntPtr:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough fallthrough
@ -948,6 +1031,44 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadOmitEmptyIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
p = e.ptrToPtr(p)
if p == 0 {
code = code.nextField
} else {
b = append(b, code.key...)
b = appendInt(b, int64(e.ptrToInt(p)))
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringTagIntPtr:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadStringTagIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
b = append(b, code.key...)
p = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrAnonymousHeadIntPtrOnly: case opStructFieldPtrAnonymousHeadIntPtrOnly:
p := load(ctxptr, code.idx) p := load(ctxptr, code.idx)
if p == 0 { if p == 0 {
@ -966,6 +1087,44 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtrOnly:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
case opStructFieldAnonymousHeadOmitEmptyIntPtrOnly:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.nextField
} else {
b = append(b, code.key...)
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringTagIntPtrOnly:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
case opStructFieldAnonymousHeadStringTagIntPtrOnly:
p := load(ctxptr, code.idx)
b = append(b, code.key...)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadInt8: case opStructFieldPtrHeadInt8:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough fallthrough
@ -2839,49 +2998,6 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
} }
case opStructFieldPtrHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
case opStructFieldHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
b = append(b, '{')
p := ptr + code.offset
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
code = code.nextField
} else {
b = append(b, code.key...)
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldPtrAnonymousHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
case opStructFieldAnonymousHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
p := ptr + code.offset
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
code = code.nextField
} else {
b = append(b, code.key...)
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldPtrHeadOmitEmptyInt8: case opStructFieldPtrHeadOmitEmptyInt8:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
if ptr != 0 { if ptr != 0 {
@ -5175,7 +5291,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset) p := e.ptrToPtr(ptr + code.offset)
if p == 0 { if p == 0 {
b = append(b, `""`...) b = encodeNull(b)
} else { } else {
b = append(b, '"') b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p))) b = appendInt(b, int64(e.ptrToInt(p)))

View File

@ -577,15 +577,49 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
code = code.next code = code.next
store(ctxptr, code.idx, p) store(ctxptr, code.idx, p)
} }
case opStructFieldHeadOnly: case opStructFieldPtrHeadOmitEmpty:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
case opStructFieldHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
b = append(b, '{')
p := ptr + code.offset
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly:
p := load(ctxptr, code.idx)
b = append(b, '{') b = append(b, '{')
if !code.anonymousKey { if !code.anonymousKey {
b = append(b, code.escapedKey...) b = append(b, code.escapedKey...)
} }
p := ptr + code.offset
code = code.next code = code.next
store(ctxptr, code.idx, p) store(ctxptr, code.idx, p)
case opStructFieldHeadOmitEmptyOnly:
p := load(ctxptr, code.idx)
b = append(b, '{')
if !code.anonymousKey {
if p != 0 {
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
} else {
code = code.nextField
}
}
case opStructFieldAnonymousHead: case opStructFieldAnonymousHead:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
if ptr == 0 { if ptr == 0 {
@ -594,6 +628,26 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
code = code.next code = code.next
store(ctxptr, code.idx, ptr) store(ctxptr, code.idx, ptr)
} }
case opStructFieldPtrAnonymousHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
case opStructFieldAnonymousHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
p := ptr + code.offset
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldPtrHeadInt: case opStructFieldPtrHeadInt:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough fallthrough
@ -737,7 +791,7 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
b = append(b, code.escapedKey...) b = append(b, code.escapedKey...)
p = e.ptrToPtr(p) p = e.ptrToPtr(p)
if p == 0 { if p == 0 {
b = append(b, `""`...) b = encodeNull(b)
} else { } else {
b = append(b, '"') b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset))) b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
@ -801,7 +855,7 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
b = append(b, '{') b = append(b, '{')
b = append(b, code.escapedKey...) b = append(b, code.escapedKey...)
if p == 0 { if p == 0 {
b = append(b, `""`...) b = encodeNull(b)
} else { } else {
b = append(b, '"') b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset))) b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
@ -892,6 +946,33 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
} }
case opStructFieldPtrAnonymousHeadOmitEmptyIntOnly, opStructFieldAnonymousHeadOmitEmptyIntOnly:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToInt(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(v))
b = encodeComma(b)
code = code.next
}
}
case opStructFieldPtrAnonymousHeadStringTagIntOnly, opStructFieldAnonymousHeadStringTagIntOnly:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
b = append(b, '"')
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadIntPtr: case opStructFieldPtrAnonymousHeadIntPtr:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough fallthrough
@ -910,6 +991,44 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadOmitEmptyIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
p = e.ptrToPtr(p)
if p == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt(p)))
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringTagIntPtr:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadStringTagIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
b = append(b, code.escapedKey...)
p = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrAnonymousHeadIntPtrOnly: case opStructFieldPtrAnonymousHeadIntPtrOnly:
p := load(ctxptr, code.idx) p := load(ctxptr, code.idx)
if p == 0 { if p == 0 {
@ -928,6 +1047,44 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
} }
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtrOnly:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
case opStructFieldAnonymousHeadOmitEmptyIntPtrOnly:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringTagIntPtrOnly:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
case opStructFieldAnonymousHeadStringTagIntPtrOnly:
p := load(ctxptr, code.idx)
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadInt8: case opStructFieldPtrHeadInt8:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough fallthrough
@ -2808,49 +2965,6 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
} }
case opStructFieldPtrHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
case opStructFieldHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
b = append(b, '{')
p := ptr + code.offset
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldPtrAnonymousHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
case opStructFieldAnonymousHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
p := ptr + code.offset
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldPtrHeadOmitEmptyInt8: case opStructFieldPtrHeadOmitEmptyInt8:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
if ptr != 0 { if ptr != 0 {
@ -5203,7 +5317,7 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset) p := e.ptrToPtr(ptr + code.offset)
if p == 0 { if p == 0 {
b = append(b, `""`...) b = encodeNull(b)
} else { } else {
b = append(b, '"') b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p))) b = appendInt(b, int64(e.ptrToInt(p)))

View File

@ -617,7 +617,34 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
code = code.next code = code.next
store(ctxptr, code.idx, p) store(ctxptr, code.idx, p)
} }
case opStructFieldHeadOnly: case opStructFieldPtrHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
case opStructFieldHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = e.encodeIndent(b, code.indent)
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.end.next
} else {
b = e.encodeIndent(b, code.indent)
b = append(b, '{', '\n')
p := ptr + code.offset
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
code = code.nextField
} else {
b = e.encodeIndent(b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
b = append(b, '{', '\n') b = append(b, '{', '\n')
if !code.anonymousKey { if !code.anonymousKey {
@ -628,6 +655,19 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
p := ptr + code.offset p := ptr + code.offset
code = code.next code = code.next
store(ctxptr, code.idx, p) store(ctxptr, code.idx, p)
case opStructFieldHeadOmitEmptyOnly:
ptr := load(ctxptr, code.idx)
b = append(b, '{', '\n')
if !code.anonymousKey && ptr != 0 {
b = e.encodeIndent(b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
p := ptr + code.offset
code = code.next
store(ctxptr, code.idx, p)
} else {
code = code.nextField
}
case opStructFieldPtrHeadInt: case opStructFieldPtrHeadInt:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough fallthrough
@ -787,7 +827,7 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
b = append(b, ' ') b = append(b, ' ')
p = e.ptrToPtr(p) p = e.ptrToPtr(p)
if p == 0 { if p == 0 {
b = append(b, `""`...) b = encodeNull(b)
} else { } else {
b = append(b, '"') b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset))) b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
@ -857,7 +897,7 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
b = append(b, code.escapedKey...) b = append(b, code.escapedKey...)
b = append(b, ' ') b = append(b, ' ')
if p == 0 { if p == 0 {
b = append(b, `""`...) b = encodeNull(b)
} else { } else {
b = append(b, '"') b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset))) b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
@ -903,6 +943,43 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
} }
case opStructFieldPtrAnonymousHeadOmitEmptyInt:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadOmitEmptyInt:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToInt(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = e.encodeIndent(b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendInt(b, int64(v))
b = encodeIndentComma(b)
code = code.next
}
}
case opStructFieldPtrAnonymousHeadStringTagInt:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadStringTagInt:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
b = e.encodeIndent(b, code.indent)
b = append(b, code.key...)
b = append(b, ' ')
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
b = append(b, '"')
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadIntOnly, opStructFieldAnonymousHeadIntOnly: case opStructFieldPtrAnonymousHeadIntOnly, opStructFieldAnonymousHeadIntOnly:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
if ptr == 0 { if ptr == 0 {
@ -915,6 +992,37 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
} }
case opStructFieldPtrAnonymousHeadOmitEmptyIntOnly, opStructFieldAnonymousHeadOmitEmptyIntOnly:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToInt(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = e.encodeIndent(b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendInt(b, int64(v))
b = encodeIndentComma(b)
code = code.next
}
}
case opStructFieldPtrAnonymousHeadStringTagIntOnly, opStructFieldAnonymousHeadStringTagIntOnly:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
b = e.encodeIndent(b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
b = append(b, '"')
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadIntPtr: case opStructFieldPtrAnonymousHeadIntPtr:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough fallthrough
@ -935,6 +1043,48 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
} }
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadOmitEmptyIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
p = e.ptrToPtr(p)
if p == 0 {
code = code.nextField
} else {
b = e.encodeIndent(b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendInt(b, int64(e.ptrToInt(p)))
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringTagIntPtr:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadStringTagIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
b = e.encodeIndent(b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
p = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
b = append(b, '"')
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrAnonymousHeadIntPtrOnly: case opStructFieldPtrAnonymousHeadIntPtrOnly:
p := load(ctxptr, code.idx) p := load(ctxptr, code.idx)
if p == 0 { if p == 0 {
@ -955,6 +1105,48 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
} }
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtrOnly:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
case opStructFieldAnonymousHeadOmitEmptyIntPtrOnly:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.nextField
} else {
b = e.encodeIndent(b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringTagIntPtrOnly:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
case opStructFieldAnonymousHeadStringTagIntPtrOnly:
p := load(ctxptr, code.idx)
b = e.encodeIndent(b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
b = append(b, '"')
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadInt8: case opStructFieldPtrHeadInt8:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough fallthrough
@ -2855,33 +3047,6 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
} }
case opStructFieldPtrHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
case opStructFieldHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = e.encodeIndent(b, code.indent)
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.end.next
} else {
b = e.encodeIndent(b, code.indent)
b = append(b, '{', '\n')
p := ptr + code.offset
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
code = code.nextField
} else {
b = e.encodeIndent(b, code.indent+1)
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldPtrHeadOmitEmptyInt8: case opStructFieldPtrHeadOmitEmptyInt8:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
if ptr != 0 { if ptr != 0 {
@ -3286,7 +3451,6 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
case opStructFieldHeadStringTag: case opStructFieldHeadStringTag:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
if ptr == 0 { if ptr == 0 {
b = e.encodeIndent(b, code.indent)
b = encodeNull(b) b = encodeNull(b)
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.end.next code = code.end.next
@ -4390,7 +4554,7 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset) p := e.ptrToPtr(ptr + code.offset)
if p == 0 { if p == 0 {
b = append(b, `""`...) b = encodeNull(b)
} else { } else {
b = append(b, '"') b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p))) b = appendInt(b, int64(e.ptrToInt(p)))

View File

@ -617,7 +617,34 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
code = code.next code = code.next
store(ctxptr, code.idx, p) store(ctxptr, code.idx, p)
} }
case opStructFieldHeadOnly: case opStructFieldPtrHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
case opStructFieldHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = e.encodeIndent(b, code.indent)
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.end.next
} else {
b = e.encodeIndent(b, code.indent)
b = append(b, '{', '\n')
p := ptr + code.offset
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
code = code.nextField
} else {
b = e.encodeIndent(b, code.indent+1)
b = append(b, code.key...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
b = append(b, '{', '\n') b = append(b, '{', '\n')
if !code.anonymousKey { if !code.anonymousKey {
@ -628,6 +655,19 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
p := ptr + code.offset p := ptr + code.offset
code = code.next code = code.next
store(ctxptr, code.idx, p) store(ctxptr, code.idx, p)
case opStructFieldHeadOmitEmptyOnly:
ptr := load(ctxptr, code.idx)
b = append(b, '{', '\n')
if !code.anonymousKey && ptr != 0 {
b = e.encodeIndent(b, code.indent+1)
b = append(b, code.key...)
b = append(b, ' ')
p := ptr + code.offset
code = code.next
store(ctxptr, code.idx, p)
} else {
code = code.nextField
}
case opStructFieldPtrHeadInt: case opStructFieldPtrHeadInt:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough fallthrough
@ -787,7 +827,7 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
b = append(b, ' ') b = append(b, ' ')
p = e.ptrToPtr(p) p = e.ptrToPtr(p)
if p == 0 { if p == 0 {
b = append(b, `""`...) b = encodeNull(b)
} else { } else {
b = append(b, '"') b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset))) b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
@ -857,7 +897,7 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
b = append(b, code.key...) b = append(b, code.key...)
b = append(b, ' ') b = append(b, ' ')
if p == 0 { if p == 0 {
b = append(b, `""`...) b = encodeNull(b)
} else { } else {
b = append(b, '"') b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset))) b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
@ -903,6 +943,43 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
} }
case opStructFieldPtrAnonymousHeadOmitEmptyInt:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadOmitEmptyInt:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToInt(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = e.encodeIndent(b, code.indent)
b = append(b, code.key...)
b = append(b, ' ')
b = appendInt(b, int64(v))
b = encodeIndentComma(b)
code = code.next
}
}
case opStructFieldPtrAnonymousHeadStringTagInt:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadStringTagInt:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
b = e.encodeIndent(b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
b = append(b, '"')
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadIntOnly, opStructFieldAnonymousHeadIntOnly: case opStructFieldPtrAnonymousHeadIntOnly, opStructFieldAnonymousHeadIntOnly:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
if ptr == 0 { if ptr == 0 {
@ -915,6 +992,37 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
} }
case opStructFieldPtrAnonymousHeadOmitEmptyIntOnly, opStructFieldAnonymousHeadOmitEmptyIntOnly:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
v := e.ptrToInt(ptr + code.offset)
if v == 0 {
code = code.nextField
} else {
b = e.encodeIndent(b, code.indent)
b = append(b, code.key...)
b = append(b, ' ')
b = appendInt(b, int64(v))
b = encodeIndentComma(b)
code = code.next
}
}
case opStructFieldPtrAnonymousHeadStringTagIntOnly, opStructFieldAnonymousHeadStringTagIntOnly:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
code = code.end.next
} else {
b = e.encodeIndent(b, code.indent)
b = append(b, code.key...)
b = append(b, ' ')
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
b = append(b, '"')
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadIntPtr: case opStructFieldPtrAnonymousHeadIntPtr:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough fallthrough
@ -935,6 +1043,48 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
} }
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadOmitEmptyIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
p = e.ptrToPtr(p)
if p == 0 {
code = code.nextField
} else {
b = e.encodeIndent(b, code.indent)
b = append(b, code.key...)
b = append(b, ' ')
b = appendInt(b, int64(e.ptrToInt(p)))
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringTagIntPtr:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough
case opStructFieldAnonymousHeadStringTagIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
b = e.encodeIndent(b, code.indent)
b = append(b, code.key...)
b = append(b, ' ')
p = e.ptrToPtr(p)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
b = append(b, '"')
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrAnonymousHeadIntPtrOnly: case opStructFieldPtrAnonymousHeadIntPtrOnly:
p := load(ctxptr, code.idx) p := load(ctxptr, code.idx)
if p == 0 { if p == 0 {
@ -955,6 +1105,48 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
} }
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtrOnly:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
case opStructFieldAnonymousHeadOmitEmptyIntPtrOnly:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.nextField
} else {
b = e.encodeIndent(b, code.indent)
b = append(b, code.key...)
b = append(b, ' ')
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
b = encodeIndentComma(b)
code = code.next
}
case opStructFieldPtrAnonymousHeadStringTagIntPtrOnly:
p := load(ctxptr, code.idx)
if p == 0 {
code = code.end.next
break
}
store(ctxptr, code.idx, e.ptrToPtr(p))
fallthrough
case opStructFieldAnonymousHeadStringTagIntPtrOnly:
p := load(ctxptr, code.idx)
b = e.encodeIndent(b, code.indent)
b = append(b, code.key...)
b = append(b, ' ')
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
b = append(b, '"')
}
b = encodeIndentComma(b)
code = code.next
case opStructFieldPtrHeadInt8: case opStructFieldPtrHeadInt8:
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx))) store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
fallthrough fallthrough
@ -2855,33 +3047,6 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
} }
case opStructFieldPtrHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr != 0 {
store(ctxptr, code.idx, e.ptrToPtr(ptr))
}
fallthrough
case opStructFieldHeadOmitEmpty:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = e.encodeIndent(b, code.indent)
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.end.next
} else {
b = e.encodeIndent(b, code.indent)
b = append(b, '{', '\n')
p := ptr + code.offset
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
code = code.nextField
} else {
b = e.encodeIndent(b, code.indent+1)
b = append(b, code.key...)
b = append(b, ' ')
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldPtrHeadOmitEmptyInt8: case opStructFieldPtrHeadOmitEmptyInt8:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
if ptr != 0 { if ptr != 0 {
@ -3286,7 +3451,6 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
case opStructFieldHeadStringTag: case opStructFieldHeadStringTag:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
if ptr == 0 { if ptr == 0 {
b = e.encodeIndent(b, code.indent)
b = encodeNull(b) b = encodeNull(b)
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.end.next code = code.end.next
@ -4390,7 +4554,7 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
ptr := load(ctxptr, code.headIdx) ptr := load(ctxptr, code.headIdx)
p := e.ptrToPtr(ptr + code.offset) p := e.ptrToPtr(ptr + code.offset)
if p == 0 { if p == 0 {
b = append(b, `""`...) b = encodeNull(b)
} else { } else {
b = append(b, '"') b = append(b, '"')
b = appendInt(b, int64(e.ptrToInt(p))) b = appendInt(b, int64(e.ptrToInt(p)))