[chore] update go dependencies (#4304)

- github.com/KimMachineGun/automemlimit v0.7.2 => v0.7.3
- github.com/gin-contrib/cors v1.7.5 => v1.7.6
- github.com/minio/minio-go/v7 v7.0.92 => v7.0.94
- github.com/spf13/cast v1.8.0 => v1.9.2
- github.com/uptrace/bun{,/*} v1.2.11 => v1.2.14
- golang.org/x/image v0.27.0 => v0.28.0
- golang.org/x/net v0.40.0 => v0.41.0
- code.superseriousbusiness.org/go-swagger v0.31.0-gts-go1.23-fix => v0.32.3-gts-go1.23-fix

Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4304
Co-authored-by: kim <grufwub@gmail.com>
Co-committed-by: kim <grufwub@gmail.com>
This commit is contained in:
kim 2025-06-30 15:19:09 +02:00 committed by kim
commit 8b0ea56027
294 changed files with 139999 additions and 21873 deletions

View file

@ -4,3 +4,6 @@
[submodule "tools/simde"]
path = tools/simde
url = https://github.com/simd-everywhere/simde.git
[submodule "fuzz/go-fuzz-corpus"]
path = fuzz/go-fuzz-corpus
url = https://github.com/dvyukov/go-fuzz-corpus.git

View file

@ -385,12 +385,12 @@ See [ast/visitor.go](https://github.com/bytedance/sonic/blob/main/ast/visitor.go
## Compatibility
For developers who want to use sonic to meet diffirent scenarios, we provide some integrated configs as `sonic.API`
For developers who want to use sonic to meet different scenarios, we provide some integrated configs as `sonic.API`
- `ConfigDefault`: the sonic's default config (`EscapeHTML=false`,`SortKeys=false`...) to run sonic fast meanwhile ensure security.
- `ConfigStd`: the std-compatible config (`EscapeHTML=true`,`SortKeys=true`...)
- `ConfigFastest`: the fastest config (`NoQuoteTextMarshaler=true`) to run on sonic as fast as possible.
Sonic **DOES NOT** ensure to support all environments, due to the difficulty of developing high-performance codes. On non-sonic-supporting environment, the implementation will fall back to `encoding/json`. Thus beflow configs will all equal to `ConfigStd`.
Sonic **DOES NOT** ensure to support all environments, due to the difficulty of developing high-performance codes. On non-sonic-supporting environment, the implementation will fall back to `encoding/json`. Thus below configs will all equal to `ConfigStd`.
## Tips

View file

@ -94,6 +94,9 @@ type Config struct {
// Encode Infinity or Nan float into `null`, instead of returning an error.
EncodeNullForInfOrNan bool
// CaseSensitive indicates that the decoder should not ignore the case of object keys.
CaseSensitive bool
}
var (
@ -111,7 +114,6 @@ var (
// ConfigFastest is the fastest config of APIs, aiming at speed.
ConfigFastest = Config{
NoQuoteTextMarshaler: true,
NoValidateJSONMarshaler: true,
NoValidateJSONSkip: true,
}.Froze()

View file

@ -176,7 +176,7 @@ type Scanner func(path Sequence, node *Node) bool
// Especially, if the node is not V_ARRAY or V_OBJECT,
// the node itself will be returned and Sequence.Index == -1.
//
// NOTICE: A unsetted node WON'T trigger sc, but its index still counts into Path.Index
// NOTICE: An unset node WON'T trigger sc, but its index still counts into Path.Index
func (self *Node) ForEach(sc Scanner) error {
if err := self.checkRaw(); err != nil {
return err

View file

@ -509,6 +509,23 @@ func (self *Node) Float64() (float64, error) {
}
}
func (self *Node) StrictBool() (bool, error) {
if err := self.checkRaw(); err!= nil {
return false, err
}
switch self.t {
case types.V_TRUE : return true, nil
case types.V_FALSE : return false, nil
case _V_ANY :
any := self.packAny()
switch v := any.(type) {
case bool : return v, nil
default : return false, ErrUnsupportType
}
default : return false, ErrUnsupportType
}
}
// Float64 exports underlying float64 value, including V_NUMBER, V_ANY
func (self *Node) StrictFloat64() (float64, error) {
if err := self.checkRaw(); err != nil {
@ -776,7 +793,7 @@ func (self *Node) Pop() error {
}
// Move moves the child at src index to dst index,
// meanwhile slides sliblings from src+1 to dst.
// meanwhile slides siblings from src+1 to dst.
//
// WARN: this will change address of elements, which is a dangerous action.
func (self *Node) Move(dst, src int) error {
@ -816,7 +833,7 @@ func (self *Node) Move(dst, src int) error {
return nil
}
// SetAny wraps val with V_ANY node, and Add() the node.
// AddAny wraps val with V_ANY node, and Add() the node.
func (self *Node) AddAny(val interface{}) error {
return self.Add(NewAny(val))
}
@ -938,7 +955,7 @@ func (self *Node) Map() (map[string]interface{}, error) {
return self.toGenericObject()
}
// MapUseNumber loads all keys of an object node, with numeric nodes casted to json.Number
// MapUseNumber loads all keys of an object node, with numeric nodes cast to json.Number
func (self *Node) MapUseNumber() (map[string]interface{}, error) {
if self.isAny() {
any := self.packAny()
@ -1083,7 +1100,7 @@ func (self *Node) Array() ([]interface{}, error) {
return self.toGenericArray()
}
// ArrayUseNumber loads all indexes of an array node, with numeric nodes casted to json.Number
// ArrayUseNumber loads all indexes of an array node, with numeric nodes cast to json.Number
func (self *Node) ArrayUseNumber() ([]interface{}, error) {
if self.isAny() {
any := self.packAny()
@ -1149,7 +1166,7 @@ func (self *Node) unsafeArray() (*linkedNodes, error) {
// Interface loads all children under all paths from this node,
// and converts itself as generic type.
// WARN: all numeric nodes are casted to float64
// WARN: all numeric nodes are cast to float64
func (self *Node) Interface() (interface{}, error) {
if err := self.checkRaw(); err != nil {
return nil, err
@ -1193,7 +1210,7 @@ func (self *Node) packAny() interface{} {
}
// InterfaceUseNumber works same with Interface()
// except numeric nodes are casted to json.Number
// except numeric nodes are cast to json.Number
func (self *Node) InterfaceUseNumber() (interface{}, error) {
if err := self.checkRaw(); err != nil {
return nil, err

View file

@ -63,7 +63,7 @@ func (self *Parser) delim() types.ParsingError {
return types.ERR_EOF
}
/* check for the delimtier */
/* check for the delimiter */
if self.s[p] != ':' {
return types.ERR_INVALID_CHAR
}
@ -82,7 +82,7 @@ func (self *Parser) object() types.ParsingError {
return types.ERR_EOF
}
/* check for the delimtier */
/* check for the delimiter */
if self.s[p] != '{' {
return types.ERR_INVALID_CHAR
}
@ -101,7 +101,7 @@ func (self *Parser) array() types.ParsingError {
return types.ERR_EOF
}
/* check for the delimtier */
/* check for the delimiter */
if self.s[p] != '[' {
return types.ERR_INVALID_CHAR
}
@ -638,7 +638,7 @@ func Loads(src string) (int, interface{}, error) {
}
}
// LoadsUseNumber parse all json into interface{}, with numeric nodes casted to json.Number
// LoadsUseNumber parse all json into interface{}, with numeric nodes cast to json.Number
func LoadsUseNumber(src string) (int, interface{}, error) {
ps := &Parser{s: src}
np, err := ps.Parse()

View file

@ -178,7 +178,7 @@ func (self *traverser) decodeArray() error {
/* allocate array space and parse every element */
if err := self.visitor.OnArrayBegin(_DEFAULT_NODE_CAP); err != nil {
if err == VisitOPSkip {
// NOTICE: for user needs to skip entiry object
// NOTICE: for user needs to skip entry object
self.parser.p -= 1
if _, e := self.parser.skipFast(); e != 0 {
return e
@ -233,7 +233,7 @@ func (self *traverser) decodeObject() error {
/* allocate object space and decode each pair */
if err := self.visitor.OnObjectBegin(_DEFAULT_NODE_CAP); err != nil {
if err == VisitOPSkip {
// NOTICE: for user needs to skip entiry object
// NOTICE: for user needs to skip entry object
self.parser.p -= 1
if _, e := self.parser.skipFast(); e != 0 {
return e
@ -328,5 +328,5 @@ func (self *traverser) decodeString(iv int64, ep int) error {
}
// If visitor return this error on `OnObjectBegin()` or `OnArrayBegin()`,
// the transverer will skip entiry object or array
// the traverser will skip entry object or array
var VisitOPSkip = errors.New("")

View file

@ -87,7 +87,17 @@ func (cfg frozenConfig) UnmarshalFromString(buf string, val interface{}) error {
if cfg.DisallowUnknownFields {
dec.DisallowUnknownFields()
}
return dec.Decode(val)
err := dec.Decode(val)
if err != nil {
return err
}
// check the trailing chars
offset := dec.InputOffset()
if t, err := dec.Token(); !(t == nil && err == io.EOF) {
return &json.SyntaxError{ Offset: offset}
}
return nil
}
// Unmarshal is implemented by sonic

View file

@ -76,11 +76,12 @@ func (self *StreamDecoder) Decode(val interface{}) (err error) {
if y := native.SkipOneFast(&src, &x); y < 0 {
if self.readMore() {
goto try_skip
} else {
err = SyntaxError{e, self.s, types.ParsingError(-s), ""}
self.setErr(err)
return
}
if self.err == nil {
self.err = SyntaxError{e, self.s, types.ParsingError(-s), ""}
self.setErr(self.err)
}
return self.err
} else {
s = y + s
e = x + s

View file

@ -12,7 +12,7 @@ import (
type Context struct {
Parser *Parser
efacePool *efacePool
Stack bounedStack
Stack boundedStack
Utf8Inv bool
}
@ -26,20 +26,20 @@ type parentStat struct {
con unsafe.Pointer
remain uint64
}
type bounedStack struct {
type boundedStack struct {
stack []parentStat
index int
}
func newStack(size int) bounedStack {
return bounedStack{
func newStack(size int) boundedStack {
return boundedStack{
stack: make([]parentStat, size + 2),
index: 0,
}
}
//go:nosplit
func (s *bounedStack) Pop() (unsafe.Pointer, int, bool){
func (s *boundedStack) Pop() (unsafe.Pointer, int, bool){
s.index--
con := s.stack[s.index].con
remain := s.stack[s.index].remain &^ (uint64(1) << 63)
@ -50,7 +50,7 @@ func (s *bounedStack) Pop() (unsafe.Pointer, int, bool){
}
//go:nosplit
func (s *bounedStack) Push(p unsafe.Pointer, remain int, isObj bool) {
func (s *boundedStack) Push(p unsafe.Pointer, remain int, isObj bool) {
s.stack[s.index].con = p
s.stack[s.index].remain = uint64(remain)
if isObj {
@ -1253,7 +1253,7 @@ func (node *Node) AsEfaceFallback(ctx *Context) (interface{}, error) {
if ctx.Parser.options & (1 << _F_use_number) != 0 {
num, ok := node.AsNumber(ctx)
if !ok {
// skip the unmacthed type
// skip the unmatched type
*node = NewNode(node.Next())
return nil, newUnmatched(node.Position(), rt.JsonNumberType)
} else {
@ -1275,13 +1275,13 @@ func (node *Node) AsEfaceFallback(ctx *Context) (interface{}, error) {
return f, nil
}
// skip the unmacthed type
// skip the unmatched type
*node = NewNode(node.Next())
return nil, newUnmatched(node.Position(), rt.Int64Type)
} else {
num, ok := node.AsF64(ctx)
if !ok {
// skip the unmacthed type
// skip the unmatched type
*node = NewNode(node.Next())
return nil, newUnmatched(node.Position(), rt.Float64Type)
} else {

View file

@ -97,17 +97,18 @@ func (self *MapIterator) append(t *rt.GoType, k unsafe.Pointer, v unsafe.Pointer
func (self *MapIterator) appendGeneric(p *_MapPair, t *rt.GoType, v reflect.Kind, k unsafe.Pointer) error {
switch v {
case reflect.Int : p.k = rt.Mem2Str(strconv.AppendInt(p.m[:0], int64(*(*int)(k)), 10)) ; return nil
case reflect.Int8 : p.k = rt.Mem2Str(strconv.AppendInt(p.m[:0], int64(*(*int8)(k)), 10)) ; return nil
case reflect.Int16 : p.k = rt.Mem2Str(strconv.AppendInt(p.m[:0], int64(*(*int16)(k)), 10)) ; return nil
case reflect.Int32 : p.k = rt.Mem2Str(strconv.AppendInt(p.m[:0], int64(*(*int32)(k)), 10)) ; return nil
case reflect.Int64 : p.k = rt.Mem2Str(strconv.AppendInt(p.m[:0], int64(*(*int64)(k)), 10)) ; return nil
case reflect.Int : p.k = rt.Mem2Str(strconv.AppendInt(p.m[:0], int64(*(*int)(k)), 10)) ; return nil
case reflect.Int8 : p.k = rt.Mem2Str(strconv.AppendInt(p.m[:0], int64(*(*int8)(k)), 10)) ; return nil
case reflect.Int16 : p.k = rt.Mem2Str(strconv.AppendInt(p.m[:0], int64(*(*int16)(k)), 10)) ; return nil
case reflect.Int32 : p.k = rt.Mem2Str(strconv.AppendInt(p.m[:0], int64(*(*int32)(k)), 10)) ; return nil
case reflect.Int64 : p.k = rt.Mem2Str(strconv.AppendInt(p.m[:0], int64(*(*int64)(k)), 10)) ; return nil
case reflect.Uint : p.k = rt.Mem2Str(strconv.AppendUint(p.m[:0], uint64(*(*uint)(k)), 10)) ; return nil
case reflect.Uint8 : p.k = rt.Mem2Str(strconv.AppendUint(p.m[:0], uint64(*(*uint8)(k)), 10)) ; return nil
case reflect.Uint16 : p.k = rt.Mem2Str(strconv.AppendUint(p.m[:0], uint64(*(*uint16)(k)), 10)) ; return nil
case reflect.Uint32 : p.k = rt.Mem2Str(strconv.AppendUint(p.m[:0], uint64(*(*uint32)(k)), 10)) ; return nil
case reflect.Uint64 : p.k = rt.Mem2Str(strconv.AppendUint(p.m[:0], uint64(*(*uint64)(k)), 10)) ; return nil
case reflect.Uint64 : p.k = rt.Mem2Str(strconv.AppendUint(p.m[:0], uint64(*(*uint64)(k)), 10)) ; return nil
case reflect.Uintptr : p.k = rt.Mem2Str(strconv.AppendUint(p.m[:0], uint64(*(*uintptr)(k)), 10)) ; return nil
case reflect.Bool : if *(*bool)(k) { p.k = "true" } else { p.k = "false" }; return nil
case reflect.Interface : return self.appendInterface(p, t, k)
case reflect.Struct, reflect.Ptr : return self.appendConcrete(p, t, k)
default : panic("unexpected map key type")

View file

@ -21,6 +21,7 @@ package alg
import (
"runtime"
"strconv"
"unsafe"
"github.com/bytedance/sonic/internal/native"
@ -177,22 +178,9 @@ func F32toa(buf []byte, v float32) ([]byte) {
}
func I64toa(buf []byte, v int64) ([]byte) {
buf = rt.GuardSlice2(buf, 32)
ret := native.I64toa((*byte)(rt.IndexByte(buf, len(buf))), v)
if ret > 0 {
return buf[:len(buf)+ret]
} else {
return buf
}
return strconv.AppendInt(buf, v, 10)
}
func U64toa(buf []byte, v uint64) ([]byte) {
buf = rt.GuardSlice2(buf, 32)
ret := native.U64toa((*byte)(rt.IndexByte(buf, len(buf))), v)
if ret > 0 {
return buf[:len(buf)+ret]
} else {
return buf
}
return strconv.AppendUint(buf, v, 10)
}

View file

@ -324,7 +324,7 @@ func (self *NormalFieldMap) Set(fields []resolver.FieldMeta) {
}
// use hashnap
// use hashmap
type FallbackFieldMap struct {
oders []string
inner map[string]int

View file

@ -90,6 +90,9 @@ func (cfg Config) Froze() API {
if cfg.ValidateString {
api.decoderOpts |= decoder.OptionValidateString
}
if cfg.CaseSensitive {
api.decoderOpts |= decoder.OptionCaseSensitive
}
return api
}

View file

@ -62,7 +62,7 @@ func CorrectWith(dst []byte, src []byte, repl string) []byte {
return dst
}
// Validate is a simd-accelereated drop-in replacement for the standard library's utf8.Valid.
// Validate is a simd-accelerated drop-in replacement for the standard library's utf8.Valid.
func Validate(src []byte) bool {
if src == nil {
return true