mirror of https://github.com/goccy/go-json.git
Refactor encoding of structHead and structKey
This commit is contained in:
parent
102554cbcd
commit
6ae63e3e61
|
@ -1050,7 +1050,6 @@ func compiledCode(ctx *compileContext) *Opcode {
|
|||
}
|
||||
|
||||
func structHeader(ctx *compileContext, fieldCode *Opcode, valueCode *Opcode, tag *runtime.StructTag) *Opcode {
|
||||
fieldCode.Indent--
|
||||
op := optimizeStructHeader(valueCode, tag)
|
||||
fieldCode.Op = op
|
||||
fieldCode.Mask = valueCode.Mask
|
||||
|
|
|
@ -76,6 +76,14 @@ func appendComma(b []byte) []byte {
|
|||
return append(b, ',')
|
||||
}
|
||||
|
||||
func appendStructKey(_ *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte {
|
||||
return append(b, code.Key...)
|
||||
}
|
||||
|
||||
func appendStructHead(b []byte) []byte {
|
||||
return append(b, '{')
|
||||
}
|
||||
|
||||
func appendStructEnd(b []byte) []byte {
|
||||
return append(b, '}', ',')
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -76,6 +76,14 @@ func appendComma(b []byte) []byte {
|
|||
return append(b, ',')
|
||||
}
|
||||
|
||||
func appendStructKey(_ *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte {
|
||||
return append(b, code.Key...)
|
||||
}
|
||||
|
||||
func appendStructHead(b []byte) []byte {
|
||||
return append(b, '{')
|
||||
}
|
||||
|
||||
func appendStructEnd(b []byte) []byte {
|
||||
return append(b, '}', ',')
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -76,6 +76,14 @@ func appendComma(b []byte) []byte {
|
|||
return append(b, ',')
|
||||
}
|
||||
|
||||
func appendStructHead(b []byte) []byte {
|
||||
return append(b, '{')
|
||||
}
|
||||
|
||||
func appendStructKey(_ *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte {
|
||||
return append(b, code.EscapedKey...)
|
||||
}
|
||||
|
||||
func appendStructEnd(b []byte) []byte {
|
||||
return append(b, '}', ',')
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -76,6 +76,16 @@ func appendComma(b []byte) []byte {
|
|||
return append(b, ',', '\n')
|
||||
}
|
||||
|
||||
func appendStructHead(b []byte) []byte {
|
||||
return append(b, '{', '\n')
|
||||
}
|
||||
|
||||
func appendStructKey(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte {
|
||||
b = appendIndent(ctx, b, code.Indent)
|
||||
b = append(b, code.EscapedKey...)
|
||||
return append(b, ' ')
|
||||
}
|
||||
|
||||
func appendStructEndSkipLast(ctx *encoder.RuntimeContext, b []byte, code *encoder.Opcode) []byte {
|
||||
last := len(b) - 1
|
||||
if b[last-1] == '{' {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -76,6 +76,16 @@ func appendComma(b []byte) []byte {
|
|||
return append(b, ',', '\n')
|
||||
}
|
||||
|
||||
func appendStructHead(b []byte) []byte {
|
||||
return append(b, '{', '\n')
|
||||
}
|
||||
|
||||
func appendStructKey(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte {
|
||||
b = appendIndent(ctx, b, code.Indent)
|
||||
b = append(b, code.Key...)
|
||||
return append(b, ' ')
|
||||
}
|
||||
|
||||
func appendStructEndSkipLast(ctx *encoder.RuntimeContext, b []byte, code *encoder.Opcode) []byte {
|
||||
last := len(b) - 1
|
||||
if b[last-1] == '{' {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue