diff options
author | 2024-05-06 19:44:22 +0000 | |
---|---|---|
committer | 2024-05-06 19:44:22 +0000 | |
commit | 3554991444c979c8c4fabc62383d1a032ae3e5fe (patch) | |
tree | 63cbd222bff33ab603ac024ba02c1a6d8ea454c7 /vendor/codeberg.org | |
parent | feature: filters v2 server-side warning/hiding (#2793) (diff) | |
download | gotosocial-3554991444c979c8c4fabc62383d1a032ae3e5fe.tar.xz |
update go-structr -> v0.8.2 which includes some minor memory usage improvements (#2904)
Diffstat (limited to 'vendor/codeberg.org')
-rw-r--r-- | vendor/codeberg.org/gruf/go-structr/cache.go | 14 | ||||
-rw-r--r-- | vendor/codeberg.org/gruf/go-structr/item.go | 6 | ||||
-rw-r--r-- | vendor/codeberg.org/gruf/go-structr/queue.go | 6 |
3 files changed, 25 insertions, 1 deletions
diff --git a/vendor/codeberg.org/gruf/go-structr/cache.go b/vendor/codeberg.org/gruf/go-structr/cache.go index d9bcc58d3..17c491158 100644 --- a/vendor/codeberg.org/gruf/go-structr/cache.go +++ b/vendor/codeberg.org/gruf/go-structr/cache.go @@ -556,6 +556,12 @@ func (c *Cache[T]) Cap() int { func (c *Cache[T]) store_value(index *Index, key Key, value T) { // Alloc new index item. item := new_indexed_item() + if cap(item.indexed) < len(c.indices) { + + // Preallocate item indices slice to prevent Go auto + // allocating overlying large slices we don't need. + item.indexed = make([]*index_entry, 0, len(c.indices)) + } // Create COPY of value. value = c.copy(value) @@ -622,6 +628,14 @@ func (c *Cache[T]) store_error(index *Index, key Key, err error) { // Alloc new index item. item := new_indexed_item() + if cap(item.indexed) < len(c.indices) { + + // Preallocate item indices slice to prevent Go auto + // allocating overlying large slices we don't need. + item.indexed = make([]*index_entry, 0, len(c.indices)) + } + + // Set error val. item.data = err // Append item to index. diff --git a/vendor/codeberg.org/gruf/go-structr/item.go b/vendor/codeberg.org/gruf/go-structr/item.go index 602c5b84a..9e837e157 100644 --- a/vendor/codeberg.org/gruf/go-structr/item.go +++ b/vendor/codeberg.org/gruf/go-structr/item.go @@ -51,8 +51,12 @@ func (i *indexed_item) drop_index(entry *index_entry) { continue } + // Unset tptr value to + // ensure GC can take it. + i.indexed[x] = nil + // Move all index entries down + reslice. - copy(i.indexed[x:], i.indexed[x+1:]) + _ = copy(i.indexed[x:], i.indexed[x+1:]) i.indexed = i.indexed[:len(i.indexed)-1] break } diff --git a/vendor/codeberg.org/gruf/go-structr/queue.go b/vendor/codeberg.org/gruf/go-structr/queue.go index 91092790a..d7c21daaa 100644 --- a/vendor/codeberg.org/gruf/go-structr/queue.go +++ b/vendor/codeberg.org/gruf/go-structr/queue.go @@ -276,6 +276,12 @@ func (q *Queue[T]) pop_n(n int, next func() *list_elem) []T { func (q *Queue[T]) index(value T) *indexed_item { item := new_indexed_item() + if cap(item.indexed) < len(q.indices) { + + // Preallocate item indices slice to prevent Go auto + // allocating overlying large slices we don't need. + item.indexed = make([]*index_entry, 0, len(q.indices)) + } // Set item value. item.data = value |