mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-29 13:23:33 -06:00
[chore]: Bump codeberg.org/gruf/go-structr from 0.9.0 to 0.9.4
Bumps codeberg.org/gruf/go-structr from 0.9.0 to 0.9.4. --- updated-dependencies: - dependency-name: codeberg.org/gruf/go-structr dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
parent
85fb63f46f
commit
8279b411d4
6 changed files with 218 additions and 77 deletions
2
vendor/codeberg.org/gruf/go-mangler/helpers.go
generated
vendored
2
vendor/codeberg.org/gruf/go-mangler/helpers.go
generated
vendored
|
|
@ -1,4 +1,4 @@
|
|||
//go:build go1.19 || go1.20 || go1.21 || go1.22 || go1.23
|
||||
//go:build go1.19 && !go1.25
|
||||
|
||||
package mangler
|
||||
|
||||
|
|
|
|||
2
vendor/codeberg.org/gruf/go-structr/runtime.go
generated
vendored
2
vendor/codeberg.org/gruf/go-structr/runtime.go
generated
vendored
|
|
@ -1,4 +1,4 @@
|
|||
//go:build go1.22 || go1.23
|
||||
//go:build go1.22 && !go1.25
|
||||
|
||||
package structr
|
||||
|
||||
|
|
|
|||
273
vendor/codeberg.org/gruf/go-structr/timeline.go
generated
vendored
273
vendor/codeberg.org/gruf/go-structr/timeline.go
generated
vendored
|
|
@ -43,7 +43,7 @@ type TimelineConfig[StructType any, PK cmp.Ordered] struct {
|
|||
// case only a single field is permitted, though
|
||||
// it may be nested, and as described above the
|
||||
// type must conform to cmp.Ordered.
|
||||
PKey string
|
||||
PKey IndexConfig
|
||||
|
||||
// Indices defines indices to create
|
||||
// in the Timeline for the receiving
|
||||
|
|
@ -106,11 +106,7 @@ func (t *Timeline[T, PK]) Init(config TimelineConfig[T, PK]) {
|
|||
// The first index is created from PKey.
|
||||
t.indices = make([]Index, len(config.Indices)+1)
|
||||
t.indices[0].ptr = unsafe.Pointer(t)
|
||||
t.indices[0].init(rt, IndexConfig{
|
||||
Fields: config.PKey,
|
||||
AllowZero: true,
|
||||
Multiple: true,
|
||||
}, 0)
|
||||
t.indices[0].init(rt, config.PKey, 0)
|
||||
if len(t.indices[0].fields) > 1 {
|
||||
panic("primary key must contain only 1 field")
|
||||
}
|
||||
|
|
@ -387,6 +383,54 @@ func (t *Timeline[T, PK]) Range(dir Direction) func(yield func(T) bool) {
|
|||
}
|
||||
}
|
||||
|
||||
// RangeUnsafe is functionally similar to Range(), except it does not pass *copies* of
|
||||
// data. It allows you to operate on the data directly and modify it. As such it can also
|
||||
// be more performant to use this function, even for read-write operations.
|
||||
//
|
||||
// Please note that the entire Timeline{} will be locked for the duration of the range
|
||||
// operation, i.e. from the beginning of the first yield call until the end of the last.
|
||||
func (t *Timeline[T, PK]) RangeUnsafe(dir Direction) func(yield func(T) bool) {
|
||||
return func(yield func(T) bool) {
|
||||
if t.copy == nil {
|
||||
panic("not initialized")
|
||||
} else if yield == nil {
|
||||
panic("nil func")
|
||||
}
|
||||
|
||||
// Acquire lock.
|
||||
t.mutex.Lock()
|
||||
defer t.mutex.Unlock()
|
||||
|
||||
switch dir {
|
||||
case Asc:
|
||||
// Iterate through linked list from bottom (i.e. tail).
|
||||
for prev := t.list.tail; prev != nil; prev = prev.prev {
|
||||
|
||||
// Extract item from list element.
|
||||
item := (*timeline_item)(prev.data)
|
||||
|
||||
// Pass to given function.
|
||||
if !yield(item.data.(T)) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
case Desc:
|
||||
// Iterate through linked list from top (i.e. head).
|
||||
for next := t.list.head; next != nil; next = next.next {
|
||||
|
||||
// Extract item from list element.
|
||||
item := (*timeline_item)(next.data)
|
||||
|
||||
// Pass to given function.
|
||||
if !yield(item.data.(T)) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RangeKeys will iterate over all values for given keys in the given index.
|
||||
//
|
||||
// Please note that the entire Timeline{} will be locked for the duration of the range
|
||||
|
|
@ -430,6 +474,48 @@ func (t *Timeline[T, PK]) RangeKeys(index *Index, keys ...Key) func(yield func(T
|
|||
}
|
||||
}
|
||||
|
||||
// RangeKeysUnsafe is functionally similar to RangeKeys(), except it does not pass *copies*
|
||||
// of data. It allows you to operate on the data directly and modify it. As such it can also
|
||||
// be more performant to use this function, even for read-write operations.
|
||||
//
|
||||
// Please note that the entire Timeline{} will be locked for the duration of the range
|
||||
// operation, i.e. from the beginning of the first yield call until the end of the last.
|
||||
func (t *Timeline[T, PK]) RangeKeysUnsafe(index *Index, keys ...Key) func(yield func(T) bool) {
|
||||
return func(yield func(T) bool) {
|
||||
if t.copy == nil {
|
||||
panic("not initialized")
|
||||
} else if index == nil {
|
||||
panic("no index given")
|
||||
} else if index.ptr != unsafe.Pointer(t) {
|
||||
panic("invalid index for timeline")
|
||||
} else if yield == nil {
|
||||
panic("nil func")
|
||||
}
|
||||
|
||||
// Acquire lock.
|
||||
t.mutex.Lock()
|
||||
defer t.mutex.Unlock()
|
||||
|
||||
for _, key := range keys {
|
||||
var done bool
|
||||
|
||||
// Iterate over values in index under key.
|
||||
index.get(key.key, func(i *indexed_item) {
|
||||
|
||||
// Cast to timeline_item type.
|
||||
item := to_timeline_item(i)
|
||||
|
||||
// Pass value data to yield function.
|
||||
done = done || !yield(item.data.(T))
|
||||
})
|
||||
|
||||
if done {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Trim will remove entries from the timeline in given
|
||||
// direction, ensuring timeline is no larger than 'max'.
|
||||
// If 'max' >= t.Len(), this function is a no-op.
|
||||
|
|
@ -804,18 +890,127 @@ func (t *Timeline[T, PK]) store_one(last *list_elem, value value_with_pk[T, PK])
|
|||
t_item.data = value.v
|
||||
t_item.pk = value.kptr
|
||||
|
||||
// Get zero'th index, i.e.
|
||||
// the primary key index.
|
||||
idx0 := (&t.indices[0])
|
||||
|
||||
// Acquire key buf.
|
||||
buf := new_buffer()
|
||||
|
||||
// Convert to indexed_item ptr.
|
||||
// Calculate index key from already extracted
|
||||
// primary key, checking for zero return value.
|
||||
partptrs := []unsafe.Pointer{value.kptr}
|
||||
key := idx0.key(buf, partptrs)
|
||||
if key == "" { // i.e. (!allow_zero && pkey == zero)
|
||||
free_timeline_item(t_item)
|
||||
free_buffer(buf)
|
||||
return last
|
||||
}
|
||||
|
||||
// Convert to indexed_item pointer.
|
||||
i_item := from_timeline_item(t_item)
|
||||
|
||||
if last == nil {
|
||||
// No previous element was provided, this is
|
||||
// first insert, we need to work from head.
|
||||
|
||||
// Check for emtpy head.
|
||||
if t.list.head == nil {
|
||||
|
||||
// The easiest case, this will
|
||||
// be the first item in list.
|
||||
t.list.push_front(&t_item.elem)
|
||||
last = t.list.head // return value
|
||||
goto indexing
|
||||
}
|
||||
|
||||
// Extract head item and its primary key.
|
||||
headItem := (*timeline_item)(t.list.head.data)
|
||||
headPK := *(*PK)(headItem.pk)
|
||||
if value.k > headPK {
|
||||
|
||||
// Another easier case, this also
|
||||
// will be the first item in list.
|
||||
t.list.push_front(&t_item.elem)
|
||||
last = t.list.head // return value
|
||||
goto indexing
|
||||
}
|
||||
|
||||
// Check (and drop) if pkey is a collision!
|
||||
if value.k == headPK && is_unique(idx0.flags) {
|
||||
free_timeline_item(t_item)
|
||||
free_buffer(buf)
|
||||
return t.list.head
|
||||
}
|
||||
|
||||
// Set last = head.next
|
||||
// as next to work from.
|
||||
last = t.list.head.next
|
||||
}
|
||||
|
||||
// Iterate through list from head
|
||||
// to find location. Optimized into two
|
||||
// cases to minimize loop CPU cycles.
|
||||
if is_unique(idx0.flags) {
|
||||
for next := last; //
|
||||
next != nil; next = next.next {
|
||||
|
||||
// Extract item and it's primary key.
|
||||
nextItem := (*timeline_item)(next.data)
|
||||
nextPK := *(*PK)(nextItem.pk)
|
||||
|
||||
// If pkey smaller than
|
||||
// cursor's, keep going.
|
||||
if value.k < nextPK {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check (and drop) if
|
||||
// pkey is a collision!
|
||||
if value.k == nextPK {
|
||||
free_timeline_item(t_item)
|
||||
free_buffer(buf)
|
||||
return next
|
||||
}
|
||||
|
||||
// New pkey is larger than cursor,
|
||||
// insert into list just before it.
|
||||
t.list.insert(&t_item.elem, next.prev)
|
||||
last = next // return value
|
||||
goto indexing
|
||||
}
|
||||
} else {
|
||||
for next := last; //
|
||||
next != nil; next = next.next {
|
||||
|
||||
// Extract item and it's primary key.
|
||||
nextItem := (*timeline_item)(next.data)
|
||||
nextPK := *(*PK)(nextItem.pk)
|
||||
|
||||
// If pkey smaller than
|
||||
// cursor's, keep going.
|
||||
if value.k < nextPK {
|
||||
continue
|
||||
}
|
||||
|
||||
// New pkey is larger than cursor,
|
||||
// insert into list just before it.
|
||||
t.list.insert(&t_item.elem, next.prev)
|
||||
last = next // return value
|
||||
goto indexing
|
||||
}
|
||||
}
|
||||
|
||||
// We reached the end of the
|
||||
// list, insert at tail pos.
|
||||
t.list.push_back(&t_item.elem)
|
||||
last = t.list.tail // return value
|
||||
goto indexing
|
||||
|
||||
indexing:
|
||||
// Append already-extracted
|
||||
// primary key to 0th index.
|
||||
idx := (&t.indices[0])
|
||||
partptrs := []unsafe.Pointer{value.kptr}
|
||||
key := idx.key(buf, partptrs)
|
||||
evicted := idx.append(key, i_item)
|
||||
evicted := idx0.append(key, i_item)
|
||||
if evicted != nil {
|
||||
|
||||
// This item is no longer
|
||||
|
|
@ -858,61 +1053,7 @@ func (t *Timeline[T, PK]) store_one(last *list_elem, value value_with_pk[T, PK])
|
|||
|
||||
// Done with buf.
|
||||
free_buffer(buf)
|
||||
|
||||
if last == nil {
|
||||
// No previous element was provided, this is
|
||||
// first insert, we need to work from head.
|
||||
|
||||
// Check for emtpy head.
|
||||
if t.list.head == nil {
|
||||
|
||||
// The easiest case, this will
|
||||
// be the first item in list.
|
||||
t.list.push_front(&t_item.elem)
|
||||
return t.list.head
|
||||
}
|
||||
|
||||
// Extract head item and its primary key.
|
||||
headItem := (*timeline_item)(t.list.head.data)
|
||||
headPK := *(*PK)(headItem.pk)
|
||||
if value.k >= headPK {
|
||||
|
||||
// Another easier case, this also
|
||||
// will be the first item in list.
|
||||
t.list.push_front(&t_item.elem)
|
||||
return t.list.head
|
||||
}
|
||||
|
||||
// Set last=head
|
||||
// to work from.
|
||||
last = t.list.head
|
||||
}
|
||||
|
||||
// Iterate through linked list
|
||||
// from head to find location.
|
||||
for next := last.next; //
|
||||
next != nil; next = next.next {
|
||||
|
||||
// Extract item and it's primary key.
|
||||
nextItem := (*timeline_item)(next.data)
|
||||
nextPK := *(*PK)(nextItem.pk)
|
||||
|
||||
// If pkey smaller than
|
||||
// cursor's, keep going.
|
||||
if value.k < nextPK {
|
||||
continue
|
||||
}
|
||||
|
||||
// New pkey is larger than cursor,
|
||||
// insert into list just before it.
|
||||
t.list.insert(&t_item.elem, next.prev)
|
||||
return next
|
||||
}
|
||||
|
||||
// We reached the end of the
|
||||
// list, insert at tail pos.
|
||||
t.list.push_back(&t_item.elem)
|
||||
return t.list.tail
|
||||
return last
|
||||
}
|
||||
|
||||
func (t *Timeline[T, PK]) delete(i *timeline_item) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue