summaryrefslogtreecommitdiff
path: root/vendor/github.com/goccy/go-json/internal/encoder/code.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-06-01 22:20:16 +0100
committerLibravatar GitHub <noreply@github.com>2023-06-01 22:20:16 +0100
commit55aacaf4b07c1921061245cbaa3d307e97cf3c29 (patch)
treed969c5d9728566de1e794e19c5b19d3b660f790e /vendor/github.com/goccy/go-json/internal/encoder/code.go
parent[chore/frontend] refactor header templating, add apple-touch-icon (#1850) (diff)
downloadgotosocial-55aacaf4b07c1921061245cbaa3d307e97cf3c29.tar.xz
[chore]: Bump github.com/gin-gonic/gin from 1.9.0 to 1.9.1 (#1855)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/goccy/go-json/internal/encoder/code.go')
-rw-r--r--vendor/github.com/goccy/go-json/internal/encoder/code.go20
1 files changed, 13 insertions, 7 deletions
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/code.go b/vendor/github.com/goccy/go-json/internal/encoder/code.go
index 8d62a9cd5..5b08faefc 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/code.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/code.go
@@ -397,7 +397,10 @@ func (c *StructCode) lastFieldCode(field *StructFieldCode, firstField *Opcode) *
func (c *StructCode) lastAnonymousFieldCode(firstField *Opcode) *Opcode {
// firstField is special StructHead operation for anonymous structure.
// So, StructHead's next operation is truly struct head operation.
- lastField := firstField.Next
+ for firstField.Op == OpStructHead || firstField.Op == OpStructField {
+ firstField = firstField.Next
+ }
+ lastField := firstField
for lastField.NextField != nil {
lastField = lastField.NextField
}
@@ -437,11 +440,6 @@ func (c *StructCode) ToOpcode(ctx *compileContext) Opcodes {
}
if isEndField {
endField := fieldCodes.Last()
- if isEmbeddedStruct(field) {
- firstField.End = endField
- lastField := c.lastAnonymousFieldCode(firstField)
- lastField.NextField = endField
- }
if len(codes) > 0 {
codes.First().End = endField
} else {
@@ -698,7 +696,15 @@ func (c *StructFieldCode) addStructEndCode(ctx *compileContext, codes Opcodes) O
Indent: ctx.indent,
}
codes.Last().Next = end
- codes.First().NextField = end
+ code := codes.First()
+ for code.Op == OpStructField || code.Op == OpStructHead {
+ code = code.Next
+ }
+ for code.NextField != nil {
+ code = code.NextField
+ }
+ code.NextField = end
+
codes = codes.Add(end)
ctx.incOpcodeIndex()
return codes