处理AI胡乱生成的乱摊子
This commit is contained in:
59
vendor/github.com/bytedance/sonic/sonic.go
generated
vendored
59
vendor/github.com/bytedance/sonic/sonic.go
generated
vendored
@@ -1,4 +1,5 @@
|
||||
// +build amd64,go1.16,!go1.22
|
||||
//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26)
|
||||
// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26
|
||||
|
||||
/*
|
||||
* Copyright 2021 ByteDance Inc.
|
||||
@@ -16,7 +17,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
//go:generate make
|
||||
package sonic
|
||||
|
||||
import (
|
||||
@@ -29,6 +29,8 @@ import (
|
||||
`github.com/bytedance/sonic/internal/rt`
|
||||
)
|
||||
|
||||
const apiKind = UseSonicJSON
|
||||
|
||||
type frozenConfig struct {
|
||||
Config
|
||||
encoderOpts encoder.Options
|
||||
@@ -58,8 +60,20 @@ func (cfg Config) Froze() API {
|
||||
if cfg.ValidateString {
|
||||
api.encoderOpts |= encoder.ValidateString
|
||||
}
|
||||
if cfg.NoValidateJSONMarshaler {
|
||||
api.encoderOpts |= encoder.NoValidateJSONMarshaler
|
||||
}
|
||||
if cfg.NoEncoderNewline {
|
||||
api.encoderOpts |= encoder.NoEncoderNewline
|
||||
}
|
||||
if cfg.EncodeNullForInfOrNan {
|
||||
api.encoderOpts |= encoder.EncodeNullForInfOrNan
|
||||
}
|
||||
|
||||
// configure decoder options:
|
||||
if cfg.NoValidateJSONSkip {
|
||||
api.decoderOpts |= decoder.OptionNoValidateJSON
|
||||
}
|
||||
if cfg.UseInt64 {
|
||||
api.decoderOpts |= decoder.OptionUseInt64
|
||||
}
|
||||
@@ -75,6 +89,9 @@ func (cfg Config) Froze() API {
|
||||
if cfg.ValidateString {
|
||||
api.decoderOpts |= decoder.OptionValidateString
|
||||
}
|
||||
if cfg.CaseSensitive {
|
||||
api.decoderOpts |= decoder.OptionCaseSensitive
|
||||
}
|
||||
return api
|
||||
}
|
||||
|
||||
@@ -139,23 +156,23 @@ func (cfg frozenConfig) Valid(data []byte) bool {
|
||||
// Opts are the compile options, for example, "option.WithCompileRecursiveDepth" is
|
||||
// a compile option to set the depth of recursive compile for the nested struct type.
|
||||
func Pretouch(vt reflect.Type, opts ...option.CompileOption) error {
|
||||
if err := encoder.Pretouch(vt, opts...); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := decoder.Pretouch(vt, opts...); err != nil {
|
||||
return err
|
||||
}
|
||||
// to pretouch the corresponding pointer type as well
|
||||
if vt.Kind() == reflect.Ptr {
|
||||
vt = vt.Elem()
|
||||
} else {
|
||||
vt = reflect.PtrTo(vt)
|
||||
}
|
||||
if err := encoder.Pretouch(vt, opts...); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := decoder.Pretouch(vt, opts...); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
if err := encoder.Pretouch(vt, opts...); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := decoder.Pretouch(vt, opts...); err != nil {
|
||||
return err
|
||||
}
|
||||
// to pretouch the corresponding pointer type as well
|
||||
if vt.Kind() == reflect.Ptr {
|
||||
vt = vt.Elem()
|
||||
} else {
|
||||
vt = reflect.PtrTo(vt)
|
||||
}
|
||||
if err := encoder.Pretouch(vt, opts...); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := decoder.Pretouch(vt, opts...); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user