summaryrefslogtreecommitdiff
path: root/vendor/github.com/bytedance/sonic/ast/api_compat.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-06-01 22:20:16 +0100
committerLibravatar GitHub <noreply@github.com>2023-06-01 22:20:16 +0100
commit55aacaf4b07c1921061245cbaa3d307e97cf3c29 (patch)
treed969c5d9728566de1e794e19c5b19d3b660f790e /vendor/github.com/bytedance/sonic/ast/api_compat.go
parent[chore/frontend] refactor header templating, add apple-touch-icon (#1850) (diff)
downloadgotosocial-55aacaf4b07c1921061245cbaa3d307e97cf3c29.tar.xz
[chore]: Bump github.com/gin-gonic/gin from 1.9.0 to 1.9.1 (#1855)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/bytedance/sonic/ast/api_compat.go')
-rw-r--r--vendor/github.com/bytedance/sonic/ast/api_compat.go38
1 files changed, 28 insertions, 10 deletions
diff --git a/vendor/github.com/bytedance/sonic/ast/api_compat.go b/vendor/github.com/bytedance/sonic/ast/api_compat.go
index 642330c51..b18b5ae8c 100644
--- a/vendor/github.com/bytedance/sonic/ast/api_compat.go
+++ b/vendor/github.com/bytedance/sonic/ast/api_compat.go
@@ -1,5 +1,21 @@
// +build !amd64 go1.21
+/*
+ * Copyright 2022 ByteDance Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package ast
import (
@@ -24,8 +40,6 @@ func unquote(src string) (string, types.ParsingError) {
return rt.Mem2Str(out), 0
}
-
-
func decodeBase64(src string) ([]byte, error) {
return base64.StdEncoding.DecodeString(src)
}
@@ -53,7 +67,12 @@ func (self *Parser) skip() (int, types.ParsingError) {
}
func (self *Parser) skipFast() (int, types.ParsingError) {
- return self.skip()
+ e, s := skipValueFast(self.s, self.p)
+ if e < 0 {
+ return self.p, types.ParsingError(-e)
+ }
+ self.p = e
+ return s, 0
}
func (self *Node) encodeInterface(buf *[]byte) error {
@@ -70,17 +89,16 @@ func (self *Searcher) GetByPath(path ...interface{}) (Node, error) {
var err types.ParsingError
for _, p := range path {
- switch p := p.(type) {
- case int:
- if err = self.parser.searchIndex(p); err != 0 {
+ if idx, ok := p.(int); ok && idx >= 0 {
+ if err = self.parser.searchIndex(idx); err != 0 {
return Node{}, self.parser.ExportError(err)
}
- case string:
- if err = self.parser.searchKey(p); err != 0 {
+ } else if key, ok := p.(string); ok {
+ if err = self.parser.searchKey(key); err != 0 {
return Node{}, self.parser.ExportError(err)
}
- default:
- panic("path must be either int or string")
+ } else {
+ panic("path must be either int(>=0) or string")
}
}