mirror of https://github.com/goccy/go-json.git
Merge pull request #224 from goccy/feature/refactor-vm
Refactor encoding process of structHead and structKey
This commit is contained in:
commit
287d5f97a1
|
@ -7,7 +7,7 @@ services:
|
||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
memory: 700M
|
memory: 620M
|
||||||
working_dir: /go/src/go-json
|
working_dir: /go/src/go-json
|
||||||
command: |
|
command: |
|
||||||
sh -c "go test -c . && ls go-json.test"
|
sh -c "go test -c . && ls go-json.test"
|
||||||
|
|
|
@ -1050,7 +1050,6 @@ func compiledCode(ctx *compileContext) *Opcode {
|
||||||
}
|
}
|
||||||
|
|
||||||
func structHeader(ctx *compileContext, fieldCode *Opcode, valueCode *Opcode, tag *runtime.StructTag) *Opcode {
|
func structHeader(ctx *compileContext, fieldCode *Opcode, valueCode *Opcode, tag *runtime.StructTag) *Opcode {
|
||||||
fieldCode.Indent--
|
|
||||||
op := optimizeStructHeader(valueCode, tag)
|
op := optimizeStructHeader(valueCode, tag)
|
||||||
fieldCode.Op = op
|
fieldCode.Op = op
|
||||||
fieldCode.Mask = valueCode.Mask
|
fieldCode.Mask = valueCode.Mask
|
||||||
|
|
|
@ -76,6 +76,14 @@ func appendComma(b []byte) []byte {
|
||||||
return append(b, ',')
|
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 {
|
func appendStructEnd(b []byte) []byte {
|
||||||
return append(b, '}', ',')
|
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, ',')
|
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 {
|
func appendStructEnd(b []byte) []byte {
|
||||||
return append(b, '}', ',')
|
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, ',')
|
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 {
|
func appendStructEnd(b []byte) []byte {
|
||||||
return append(b, '}', ',')
|
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')
|
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 {
|
func appendStructEndSkipLast(ctx *encoder.RuntimeContext, b []byte, code *encoder.Opcode) []byte {
|
||||||
last := len(b) - 1
|
last := len(b) - 1
|
||||||
if b[last-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')
|
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 {
|
func appendStructEndSkipLast(ctx *encoder.RuntimeContext, b []byte, code *encoder.Opcode) []byte {
|
||||||
last := len(b) - 1
|
last := len(b) - 1
|
||||||
if b[last-1] == '{' {
|
if b[last-1] == '{' {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue