summaryrefslogtreecommitdiff
path: root/vendor/github.com/bytedance/sonic/ast/api_compat.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/bytedance/sonic/ast/api_compat.go')
-rw-r--r--vendor/github.com/bytedance/sonic/ast/api_compat.go37
1 files changed, 12 insertions, 25 deletions
diff --git a/vendor/github.com/bytedance/sonic/ast/api_compat.go b/vendor/github.com/bytedance/sonic/ast/api_compat.go
index 7b475eb61..9244e76e1 100644
--- a/vendor/github.com/bytedance/sonic/ast/api_compat.go
+++ b/vendor/github.com/bytedance/sonic/ast/api_compat.go
@@ -1,4 +1,4 @@
-// +build !amd64 !go1.16 go1.22
+// +build !amd64 !go1.16 go1.23
/*
* Copyright 2022 ByteDance Inc.
@@ -21,14 +21,13 @@ package ast
import (
`encoding/base64`
`encoding/json`
- `fmt`
`github.com/bytedance/sonic/internal/native/types`
`github.com/bytedance/sonic/internal/rt`
)
func init() {
- println("WARNING: sonic only supports Go1.16~1.20 && CPU amd64, but your environment is not suitable")
+ println("WARNING: sonic only supports Go1.16~1.22 && CPU amd64, but your environment is not suitable")
}
func quote(buf *[]byte, val string) {
@@ -88,37 +87,25 @@ 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) {
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)
- }
- 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)
- }
-
- t := switchRawType(self.parser.s[start])
- if t == _V_NONE {
- return Node{}, self.parser.ExportError(err)
+ var start int
+ if start, err = self.skip(); err != 0 {
+ return -1, err
}
-
- return newRawNode(self.parser.s[start:self.parser.p], t), nil
-} \ No newline at end of file
+ return start, 0
+}