Merge pull request #224 from goccy/feature/refactor-vm

Refactor encoding process of structHead and structKey
This commit is contained in:
Masaaki Goshima 2021-05-17 19:20:12 +09:00 committed by GitHub
commit 287d5f97a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 1675 additions and 2422 deletions

View File

@ -7,7 +7,7 @@ services:
deploy:
resources:
limits:
memory: 700M
memory: 620M
working_dir: /go/src/go-json
command: |
sh -c "go test -c . && ls go-json.test"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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