summaryrefslogtreecommitdiff
path: root/vendor/github.com/bytedance/sonic/ast/encode.go
diff options
context:
space:
mode:
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 {