From 8279b411d4f0661e77b7f44b8dd5ea9a28047338 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 06:10:34 +0000 Subject: [PATCH] [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] --- go.mod | 6 +- go.sum | 8 +- .../codeberg.org/gruf/go-mangler/helpers.go | 2 +- .../codeberg.org/gruf/go-structr/runtime.go | 2 +- .../codeberg.org/gruf/go-structr/timeline.go | 273 +++++++++++++----- vendor/modules.txt | 4 +- 6 files changed, 218 insertions(+), 77 deletions(-) diff --git a/go.mod b/go.mod index 51d5954a6..5c9c0fb1a 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/superseriousbusiness/gotosocial go 1.23.0 -toolchain go1.23.3 +toolchain go1.24.1 // Replace go-swagger with our version that fixes (ours particularly) use of Go1.23 replace github.com/go-swagger/go-swagger => codeberg.org/superseriousbusiness/go-swagger v0.31.0-gts-go1.23-fix @@ -27,7 +27,7 @@ require ( codeberg.org/gruf/go-runners v1.6.3 codeberg.org/gruf/go-sched v1.2.4 codeberg.org/gruf/go-storage v0.2.0 - codeberg.org/gruf/go-structr v0.9.0 + codeberg.org/gruf/go-structr v0.9.4 codeberg.org/superseriousbusiness/activity v1.13.0-gts codeberg.org/superseriousbusiness/exif-terminator v0.10.0 codeberg.org/superseriousbusiness/httpsig v1.3.0-SSB @@ -96,7 +96,7 @@ require ( require ( codeberg.org/gruf/go-fastpath/v2 v2.0.0 // indirect - codeberg.org/gruf/go-mangler v1.4.3 // indirect + codeberg.org/gruf/go-mangler v1.4.4 // indirect codeberg.org/gruf/go-maps v1.0.4 // indirect codeberg.org/superseriousbusiness/go-jpeg-image-structure/v2 v2.1.0-SSB // indirect codeberg.org/superseriousbusiness/go-png-image-structure/v2 v2.1.0-SSB // indirect diff --git a/go.sum b/go.sum index 18e1f2f4a..51277b287 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ codeberg.org/gruf/go-list v0.0.0-20240425093752-494db03d641f h1:Ss6Z+vygy+jOGhj9 codeberg.org/gruf/go-list v0.0.0-20240425093752-494db03d641f/go.mod h1:F9pl4h34iuVN7kucKam9fLwsItTc+9mmaKt7pNXRd/4= codeberg.org/gruf/go-loosy v0.0.0-20231007123304-bb910d1ab5c4 h1:IXwfoU7f2whT6+JKIKskNl/hBlmWmnF1vZd84Eb3cyA= codeberg.org/gruf/go-loosy v0.0.0-20231007123304-bb910d1ab5c4/go.mod h1:fiO8HE1wjZCephcYmRRsVnNI/i0+mhy44Z5dQalS0rM= -codeberg.org/gruf/go-mangler v1.4.3 h1:mdtcbGDyj0AS9LE/H1imQreICVn6BQiks554jzdAozc= -codeberg.org/gruf/go-mangler v1.4.3/go.mod h1:mDmW8Ia352RvNFaXoP9K60TgcmCZJtX0j6wm3vjAsJE= +codeberg.org/gruf/go-mangler v1.4.4 h1:moQl7FSSLLaByS7w5UP7b3Z7r2ex/F4IpvSp+PyRWK4= +codeberg.org/gruf/go-mangler v1.4.4/go.mod h1:mDmW8Ia352RvNFaXoP9K60TgcmCZJtX0j6wm3vjAsJE= codeberg.org/gruf/go-maps v1.0.4 h1:K+Ww4vvR3TZqm5jqrKVirmguZwa3v1VUvmig2SE8uxY= codeberg.org/gruf/go-maps v1.0.4/go.mod h1:ASX7osM7kFwt5O8GfGflcFjrwYGD8eIuRLl/oMjhEi8= codeberg.org/gruf/go-mempool v0.0.0-20240507125005-cef10d64a760 h1:m2/UCRXhjDwAg4vyji6iKCpomKw6P4PmBOUi5DvAMH4= @@ -38,8 +38,8 @@ codeberg.org/gruf/go-sched v1.2.4 h1:ddBB9o0D/2oU8NbQ0ldN5aWxogpXPRBATWi58+p++Hw codeberg.org/gruf/go-sched v1.2.4/go.mod h1:wad6l+OcYGWMA2TzNLMmLObsrbBDxdJfEy5WvTgBjNk= codeberg.org/gruf/go-storage v0.2.0 h1:mKj3Lx6AavEkuXXtxqPhdq+akW9YwrnP16yQBF7K5ZI= codeberg.org/gruf/go-storage v0.2.0/go.mod h1:o3GzMDE5QNUaRnm/daUzFqvuAaC4utlgXDXYO79sWKU= -codeberg.org/gruf/go-structr v0.9.0 h1:UYw8igp3I4UBnlsRyDR2AbF3g7NPEP7HBrQs1I15218= -codeberg.org/gruf/go-structr v0.9.0/go.mod h1:mUvBvn4q1iM/I+d3Fj1w/gxGUU/Ve9GpiNo6dPmBJnk= +codeberg.org/gruf/go-structr v0.9.4 h1:H4gWZe7x7kSLKbfuK8RTyZWTjDqpmuwl9vjS820ccko= +codeberg.org/gruf/go-structr v0.9.4/go.mod h1:9k5hYztZ4PsBS+m1v5hUTeFiVUBTLF5VA7d9cd1OEMs= codeberg.org/superseriousbusiness/activity v1.13.0-gts h1:4WZLc/SNt+Vt5x2UjL2n6V5dHlIL9ECudUPx8Ld5rxw= codeberg.org/superseriousbusiness/activity v1.13.0-gts/go.mod h1:enxU1Lva4OcK6b/NBXscoHSEgEMsKJvdHrQFifQxp4o= codeberg.org/superseriousbusiness/exif-terminator v0.10.0 h1:FiLX/AK07tzceS36I+kOP2aEH+aytjPSIlFoYePMEyg= diff --git a/vendor/codeberg.org/gruf/go-mangler/helpers.go b/vendor/codeberg.org/gruf/go-mangler/helpers.go index f64663e62..71d45e201 100644 --- a/vendor/codeberg.org/gruf/go-mangler/helpers.go +++ b/vendor/codeberg.org/gruf/go-mangler/helpers.go @@ -1,4 +1,4 @@ -//go:build go1.19 || go1.20 || go1.21 || go1.22 || go1.23 +//go:build go1.19 && !go1.25 package mangler diff --git a/vendor/codeberg.org/gruf/go-structr/runtime.go b/vendor/codeberg.org/gruf/go-structr/runtime.go index cd7f8d7a1..0233fafb8 100644 --- a/vendor/codeberg.org/gruf/go-structr/runtime.go +++ b/vendor/codeberg.org/gruf/go-structr/runtime.go @@ -1,4 +1,4 @@ -//go:build go1.22 || go1.23 +//go:build go1.22 && !go1.25 package structr diff --git a/vendor/codeberg.org/gruf/go-structr/timeline.go b/vendor/codeberg.org/gruf/go-structr/timeline.go index 7a9c17f70..edd6ca1a7 100644 --- a/vendor/codeberg.org/gruf/go-structr/timeline.go +++ b/vendor/codeberg.org/gruf/go-structr/timeline.go @@ -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) { diff --git a/vendor/modules.txt b/vendor/modules.txt index 5b20c6326..32ca3c496 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -38,7 +38,7 @@ codeberg.org/gruf/go-kv/format # codeberg.org/gruf/go-list v0.0.0-20240425093752-494db03d641f ## explicit; go 1.21.3 codeberg.org/gruf/go-list -# codeberg.org/gruf/go-mangler v1.4.3 +# codeberg.org/gruf/go-mangler v1.4.4 ## explicit; go 1.19 codeberg.org/gruf/go-mangler # codeberg.org/gruf/go-maps v1.0.4 @@ -63,7 +63,7 @@ codeberg.org/gruf/go-storage/disk codeberg.org/gruf/go-storage/internal codeberg.org/gruf/go-storage/memory codeberg.org/gruf/go-storage/s3 -# codeberg.org/gruf/go-structr v0.9.0 +# codeberg.org/gruf/go-structr v0.9.4 ## explicit; go 1.22 codeberg.org/gruf/go-structr # codeberg.org/superseriousbusiness/activity v1.13.0-gts