Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterDY committed Feb 29, 2024
1 parent d3ed0c0 commit 9f6c1b4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 26 deletions.
2 changes: 1 addition & 1 deletion ast/api.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.16,!go1.22 arm64,go1.20,!go1.22
// +build amd64,go1.16,!go1.23 arm64,go1.20,!go1.23

/*
* Copyright 2022 ByteDance Inc.
Expand Down
35 changes: 14 additions & 21 deletions ast/api_compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package ast

import (
`encoding/json`
`fmt`

`github.com/bytedance/sonic/internal/native/types`
`github.com/bytedance/sonic/internal/rt`
Expand Down Expand Up @@ -80,37 +79,31 @@ func (self *Node) encodeInterface(buf *[]byte) error {
return nil
}

func (self *Searcher) GetByPath(path ...interface{}) (Node, error) {
self.parser.p = 0

func (self *Parser) getByPath(path ...interface{}) (int, types.ParsingError) {

Check failure on line 82 in ast/api_compat.go

View workflow job for this annotation

GitHub Actions / build (1.22.x)

method Parser.getByPath already declared at ast/api.go:115:21

Check failure on line 82 in ast/api_compat.go

View workflow job for this annotation

GitHub Actions / build (1.22.x, arm)

method Parser.getByPath already declared at ast/api.go:115:21

Check failure on line 82 in ast/api_compat.go

View workflow job for this annotation

GitHub Actions / build (1.22.x)

method Parser.getByPath already declared at ast\api.go:115:21
var err types.ParsingError

for _, p := range path {
if idx, ok := p.(int); ok && idx >= 0 {
if err = self.parser.searchIndex(idx); err != 0 {
return Node{}, self.parser.ExportError(err)
if err = self.searchIndex(idx); err != 0 {
return -1, err
}
} else if key, ok := p.(string); ok {
if err = self.parser.searchKey(key); err != 0 {
return Node{}, self.parser.ExportError(err)
if err = self.searchKey(key); err != 0 {
return -1, err
}
} else {
panic("path must be either int(>=0) or string")
}
}

var start = self.parser.p
if start, err = self.parser.skip(); err != 0 {
return Node{}, self.parser.ExportError(err)
var start = self.p
if start, err = self.skip(); err != 0 {
return -1, err
}
ns := len(self.parser.s)
if self.parser.p > ns || start >= ns || start>=self.parser.p {
return Node{}, fmt.Errorf("skip %d char out of json boundary", start)
ns := len(self.s)
if self.p > ns || start >= ns || start>=self.p {
return -1, types.ERR_EOF
}

t := switchRawType(self.parser.s[start])
if t == _V_NONE {
return Node{}, self.parser.ExportError(err)
}

return newRawNode(self.parser.s[start:self.parser.p], t), nil

return start, 0
}
9 changes: 5 additions & 4 deletions ast/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ package ast
import (
`encoding/json`
`runtime`
`strings`
`sync`
`testing`
`strings`

`github.com/stretchr/testify/assert`
`github.com/stretchr/testify/require`
)

Expand Down Expand Up @@ -95,20 +96,20 @@ func TestEncodeNode(t *testing.T) {

type SortableNode struct {
sorted bool
*Node
*Node
}

func (j *SortableNode) UnmarshalJSON(data []byte) (error) {
j.Node = new(Node)
return j.Node.UnmarshalJSON(data)
return j.Node.UnmarshalJSON(data)
}

func (j *SortableNode) MarshalJSON() ([]byte, error) {
if !j.sorted {
j.Node.SortKeys(true)
j.sorted = true
}
return j.Node.MarshalJSON()
return j.Node.MarshalJSON()
}

func TestMarshalSort(t *testing.T) {
Expand Down

0 comments on commit 9f6c1b4

Please sign in to comment.