summaryrefslogtreecommitdiff
path: root/vendor/github.com/bytedance/sonic/ast/encode.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2024-03-11 10:12:06 +0000
committerLibravatar GitHub <noreply@github.com>2024-03-11 10:12:06 +0000
commite24efcac8b67baa9454bf27631e5e49f898a88d4 (patch)
treed9adec2f05e1d8714edee66062a4b95a81ee2a61 /vendor/github.com/bytedance/sonic/ast/encode.go
parent[bugfix] Fix whitespace move_id issue (#2742) (diff)
downloadgotosocial-e24efcac8b67baa9454bf27631e5e49f898a88d4.tar.xz
[chore]: Bump github.com/gin-contrib/cors from 1.5.0 to 1.7.0 (#2745)
Diffstat (limited to 'vendor/github.com/bytedance/sonic/ast/encode.go')
-rw-r--r--vendor/github.com/bytedance/sonic/ast/encode.go32
1 files changed, 5 insertions, 27 deletions
diff --git a/vendor/github.com/bytedance/sonic/ast/encode.go b/vendor/github.com/bytedance/sonic/ast/encode.go
index 263ae5a9d..956809c2c 100644
--- a/vendor/github.com/bytedance/sonic/ast/encode.go
+++ b/vendor/github.com/bytedance/sonic/ast/encode.go
@@ -193,20 +193,9 @@ func (self *Node) encodeArray(buf *[]byte) error {
*buf = append(*buf, '[')
- var s = (*linkedNodes)(self.p)
var started bool
- if nb > 0 {
- n := s.At(0)
- if n.Exists() {
- if err := n.encode(buf); err != nil {
- return err
- }
- started = true
- }
- }
-
- for i := 1; i < nb; i++ {
- n := s.At(i)
+ for i := 0; i < nb; i++ {
+ n := self.nodeAt(i)
if !n.Exists() {
continue
}
@@ -250,21 +239,10 @@ func (self *Node) encodeObject(buf *[]byte) error {
*buf = append(*buf, '{')
- var s = (*linkedPairs)(self.p)
var started bool
- if nb > 0 {
- n := s.At(0)
- if n.Value.Exists() {
- if err := n.encode(buf); err != nil {
- return err
- }
- started = true
- }
- }
-
- for i := 1; i < nb; i++ {
- n := s.At(i)
- if !n.Value.Exists() {
+ for i := 0; i < nb; i++ {
+ n := self.pairAt(i)
+ if n == nil || !n.Value.Exists() {
continue
}
if started {