summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-structr/queue.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-05-13 08:05:46 +0000
committerLibravatar GitHub <noreply@github.com>2024-05-13 08:05:46 +0000
commitc06e6fb6561595adc80ce5191640ae442771d45c (patch)
tree58845f63151eff4e984351575eea67f5e82a6c82 /vendor/codeberg.org/gruf/go-structr/queue.go
parent[bugfix] Reset emoji fields on upload error (#2905) (diff)
downloadgotosocial-c06e6fb6561595adc80ce5191640ae442771d45c.tar.xz
[performance] update go-structr and go-mutexes with memory usage improvements (#2909)
* update go-structr and go-mutexes with memory usage improvements * bump to go-structr v0.8.4
Diffstat (limited to 'vendor/codeberg.org/gruf/go-structr/queue.go')
-rw-r--r--vendor/codeberg.org/gruf/go-structr/queue.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/vendor/codeberg.org/gruf/go-structr/queue.go b/vendor/codeberg.org/gruf/go-structr/queue.go
index d7c21daaa..ed5d78b5a 100644
--- a/vendor/codeberg.org/gruf/go-structr/queue.go
+++ b/vendor/codeberg.org/gruf/go-structr/queue.go
@@ -214,9 +214,10 @@ func (q *Queue[T]) Debug() map[string]any {
m["indices"] = indices
for i := range q.indices {
var n uint64
- for _, list := range q.indices[i].data {
- n += uint64(list.len)
- }
+ q.indices[i].data.Iter(func(_ string, l *list) (stop bool) {
+ n += uint64(l.len)
+ return
+ })
indices[q.indices[i].name] = n
}
q.mutex.Unlock()
@@ -324,8 +325,14 @@ func (q *Queue[T]) delete(item *indexed_item) {
entry := item.indexed[len(item.indexed)-1]
item.indexed = item.indexed[:len(item.indexed)-1]
- // Drop index_entry from index.
- entry.index.delete_entry(entry)
+ // Get entry's index.
+ index := entry.index
+
+ // Drop this index_entry.
+ index.delete_entry(entry)
+
+ // Check compact.
+ index.compact()
}
// Drop entry from queue list.