mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 01:12:24 -05:00
[chore] update dependencies (#4386)
- codeberg.org/gruf/go-bytesize v1.0.3 -> v1.0.4 - codeberg.org/gruf/go-kv/v2 v2.0.6 -> v2.0.7 - codeberg.org/gruf/go-mutexes v1.5.2 -> v1.5.3 - codeberg.org/gruf/go-structr v0.9.7 -> v0.9.8 - codeberg.org/gruf/go-ffmpreg v0.6.8 -> v0.6.9 - github.com/tomnomnom/linkheader HEAD@2018 -> HEAD@2025 all of the above codeberg.org/gruf updates are in preparation for Go1.25, except for bytesize, and also ffmpreg which is a rebuild with the latest version of ffmpeg (v5.1.7) Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4386 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
8c619d51b5
commit
a79f83cbde
38 changed files with 1246 additions and 964 deletions
46
vendor/codeberg.org/gruf/go-structr/timeline.go
generated
vendored
46
vendor/codeberg.org/gruf/go-structr/timeline.go
generated
vendored
|
|
@ -5,6 +5,7 @@ import (
|
|||
"os"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"unsafe"
|
||||
)
|
||||
|
|
@ -89,7 +90,7 @@ type Timeline[StructType any, PK cmp.Ordered] struct {
|
|||
// Init initializes the timeline with given configuration
|
||||
// including struct fields to index, and necessary fns.
|
||||
func (t *Timeline[T, PK]) Init(config TimelineConfig[T, PK]) {
|
||||
rt := reflect.TypeOf((*T)(nil)).Elem()
|
||||
ti := get_type_iter[T]()
|
||||
|
||||
if len(config.Indices) == 0 {
|
||||
panic("no indices provided")
|
||||
|
|
@ -99,6 +100,17 @@ func (t *Timeline[T, PK]) Init(config TimelineConfig[T, PK]) {
|
|||
panic("copy function must be provided")
|
||||
}
|
||||
|
||||
if strings.Contains(config.PKey.Fields, ",") {
|
||||
panic("primary key must contain only 1 field")
|
||||
}
|
||||
|
||||
// Verify primary key parameter type is correct.
|
||||
names := strings.Split(config.PKey.Fields, ".")
|
||||
if _, ftype := find_field(ti, names); //
|
||||
ftype != reflect.TypeFor[PK]() {
|
||||
panic("primary key field path and generic parameter type do not match")
|
||||
}
|
||||
|
||||
// Safely copy over
|
||||
// provided config.
|
||||
t.mutex.Lock()
|
||||
|
|
@ -108,21 +120,17 @@ func (t *Timeline[T, PK]) Init(config TimelineConfig[T, PK]) {
|
|||
// other indices are created as expected.
|
||||
t.indices = make([]Index, len(config.Indices)+1)
|
||||
t.indices[0].ptr = unsafe.Pointer(t)
|
||||
t.indices[0].init(rt, config.PKey, 0)
|
||||
if len(t.indices[0].fields) > 1 {
|
||||
panic("primary key must contain only 1 field")
|
||||
}
|
||||
t.indices[0].init(ti, config.PKey, 0)
|
||||
for i, cfg := range config.Indices {
|
||||
t.indices[i+1].ptr = unsafe.Pointer(t)
|
||||
t.indices[i+1].init(rt, cfg, 0)
|
||||
t.indices[i+1].init(ti, cfg, 0)
|
||||
}
|
||||
|
||||
// Extract pkey details from index.
|
||||
field := t.indices[0].fields[0]
|
||||
t.pkey = pkey_field{
|
||||
rtype: field.rtype,
|
||||
zero: field.zero,
|
||||
offsets: field.offsets,
|
||||
likeptr: field.likeptr,
|
||||
}
|
||||
|
||||
// Copy over remaining.
|
||||
|
|
@ -220,15 +228,7 @@ func (t *Timeline[T, PK]) Insert(values ...T) int {
|
|||
|
||||
// Extract primary key from vptr.
|
||||
kptr := extract_pkey(vptr, t.pkey)
|
||||
|
||||
var pkey PK
|
||||
if kptr != nil {
|
||||
// Cast as PK type.
|
||||
pkey = *(*PK)(kptr)
|
||||
} else {
|
||||
// Use zero value pointer.
|
||||
kptr = unsafe.Pointer(&pkey)
|
||||
}
|
||||
pkey := *(*PK)(kptr)
|
||||
|
||||
// Append wrapped value to slice with
|
||||
// the acquire pointers and primary key.
|
||||
|
|
@ -241,10 +241,8 @@ func (t *Timeline[T, PK]) Insert(values ...T) int {
|
|||
}
|
||||
}
|
||||
|
||||
var last *list_elem
|
||||
|
||||
// BEFORE inserting the prepared slice of value copies w/ primary
|
||||
// keys, sort them by their primary key, ascending. This permits
|
||||
// keys, sort them by their primary key, descending. This permits
|
||||
// us to re-use the 'last' timeline position as next insert cursor.
|
||||
// Otherwise we would have to iterate from 'head' every single time.
|
||||
slices.SortFunc(with_keys, func(a, b value_with_pk[T, PK]) int {
|
||||
|
|
@ -259,6 +257,8 @@ func (t *Timeline[T, PK]) Insert(values ...T) int {
|
|||
}
|
||||
})
|
||||
|
||||
var last *list_elem
|
||||
|
||||
// Store each value in the timeline,
|
||||
// updating the last used list element
|
||||
// each time so we don't have to iter
|
||||
|
|
@ -1071,7 +1071,7 @@ indexing:
|
|||
}
|
||||
|
||||
func (t *Timeline[T, PK]) delete(i *timeline_item) {
|
||||
for len(i.indexed) != 0 {
|
||||
for len(i.indexed) > 0 {
|
||||
// Pop last indexed entry from list.
|
||||
entry := i.indexed[len(i.indexed)-1]
|
||||
i.indexed[len(i.indexed)-1] = nil
|
||||
|
|
@ -1126,9 +1126,9 @@ func from_timeline_item(item *timeline_item) *indexed_item {
|
|||
func to_timeline_item(item *indexed_item) *timeline_item {
|
||||
to := (*timeline_item)(unsafe.Pointer(item))
|
||||
if to.ck != ^uint(0) {
|
||||
// ensure check bits are set indicating
|
||||
// ensure check bits set, indicating
|
||||
// it was a timeline_item originally.
|
||||
panic(assert("check bits are set"))
|
||||
panic(assert("t.ck = ^uint(0)"))
|
||||
}
|
||||
return to
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue