diff options
| author | 2025-04-14 09:43:56 +0200 | |
|---|---|---|
| committer | 2025-04-14 09:43:56 +0200 | |
| commit | 51b9ef5c346f333e558eca38fd954464322f3b7d (patch) | |
| tree | bf5cd0de887a27c1afc66345b1a464921d96e503 /vendor/github.com/bytedance/sonic/internal/encoder/compiler.go | |
| parent | [docs] Remind the user that password resets don't work without restarting. (#... (diff) | |
| download | gotosocial-51b9ef5c346f333e558eca38fd954464322f3b7d.tar.xz | |
[chore]: Bump github.com/gin-contrib/gzip from 1.2.2 to 1.2.3 (#4000)
Bumps [github.com/gin-contrib/gzip](https://github.com/gin-contrib/gzip) from 1.2.2 to 1.2.3.
- [Release notes](https://github.com/gin-contrib/gzip/releases)
- [Changelog](https://github.com/gin-contrib/gzip/blob/master/.goreleaser.yaml)
- [Commits](https://github.com/gin-contrib/gzip/compare/v1.2.2...v1.2.3)
---
updated-dependencies:
- dependency-name: github.com/gin-contrib/gzip
dependency-version: 1.2.3
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/bytedance/sonic/internal/encoder/compiler.go')
| -rw-r--r-- | vendor/github.com/bytedance/sonic/internal/encoder/compiler.go | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/compiler.go b/vendor/github.com/bytedance/sonic/internal/encoder/compiler.go index 902fbc98b..737dd3e07 100644 --- a/vendor/github.com/bytedance/sonic/internal/encoder/compiler.go +++ b/vendor/github.com/bytedance/sonic/internal/encoder/compiler.go @@ -219,7 +219,7 @@ func (self *Compiler) compileOps(p *ir.Program, sp int, vt reflect.Type) { case reflect.Struct: self.compileStruct(p, sp, vt) default: - panic(vars.Error_type(vt)) + self.compileUnsupportedType(p, vt) } } @@ -440,7 +440,8 @@ func (self *Compiler) compileStructBody(p *ir.Program, sp int, vt reflect.Type) p.Add(ir.OP_cond_set) /* compile each field */ - for _, fv := range resolver.ResolveStruct(vt) { + fvs := resolver.ResolveStruct(vt) + for i, fv := range fvs { var s []int var o resolver.Offset @@ -463,7 +464,12 @@ func (self *Compiler) compileStructBody(p *ir.Program, sp int, vt reflect.Type) /* check for "omitempty" option */ if fv.Type.Kind() != reflect.Struct && fv.Type.Kind() != reflect.Array && (fv.Opts&resolver.F_omitempty) != 0 { s = append(s, p.PC()) - self.compileStructFieldZero(p, fv.Type) + self.compileStructFieldEmpty(p, fv.Type) + } + /* check for "omitzero" option */ + if fv.Opts&resolver.F_omitzero != 0 { + s = append(s, p.PC()) + p.VField(ir.OP_is_zero, &fvs[i]) } /* add the comma if not the first element */ @@ -574,7 +580,7 @@ func (self *Compiler) compileStructFieldStr(p *ir.Program, sp int, vt reflect.Ty } } -func (self *Compiler) compileStructFieldZero(p *ir.Program, vt reflect.Type) { +func (self *Compiler) compileStructFieldEmpty(p *ir.Program, vt reflect.Type) { switch vt.Kind() { case reflect.Bool: p.Add(ir.OP_is_zero_1) @@ -626,16 +632,16 @@ func (self *Compiler) compileStructFieldQuoted(p *ir.Program, sp int, vt reflect } func (self *Compiler) compileInterface(p *ir.Program, vt reflect.Type) { - x := p.PC() - p.Add(ir.OP_is_nil_p1) - /* iface and efaces are different */ if vt.NumMethod() == 0 { p.Add(ir.OP_eface) - } else { - p.Add(ir.OP_iface) + return } + x := p.PC() + p.Add(ir.OP_is_nil_p1) + p.Add(ir.OP_iface) + /* the "null" value */ e := p.PC() p.Add(ir.OP_goto) @@ -644,6 +650,11 @@ func (self *Compiler) compileInterface(p *ir.Program, vt reflect.Type) { p.Pin(e) } +func (self *Compiler) compileUnsupportedType(p *ir.Program, vt reflect.Type) { + p.Rtt(ir.OP_unsupported, vt) +} + + func (self *Compiler) compileMarshaler(p *ir.Program, op ir.Op, vt reflect.Type, mt reflect.Type) { pc := p.PC() vk := vt.Kind() |
