summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-structr/map.go
diff options
context:
space:
mode:
authorLibravatar Terin Stock <terinjokes@gmail.com>2025-03-09 17:47:56 +0100
committerLibravatar Terin Stock <terinjokes@gmail.com>2025-03-10 01:59:49 +0100
commit3ac1ee16f377d31a0fb80c8dae28b6239ac4229e (patch)
treef61faa581feaaeaba2542b9f2b8234a590684413 /vendor/codeberg.org/gruf/go-structr/map.go
parent[chore] update URLs to forked source (diff)
downloadgotosocial-3ac1ee16f377d31a0fb80c8dae28b6239ac4229e.tar.xz
[chore] remove vendor
Diffstat (limited to 'vendor/codeberg.org/gruf/go-structr/map.go')
-rw-r--r--vendor/codeberg.org/gruf/go-structr/map.go58
1 files changed, 0 insertions, 58 deletions
diff --git a/vendor/codeberg.org/gruf/go-structr/map.go b/vendor/codeberg.org/gruf/go-structr/map.go
deleted file mode 100644
index 316a8e528..000000000
--- a/vendor/codeberg.org/gruf/go-structr/map.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package structr
-
-type hashmap struct {
- m map[string]*list
- n int
-}
-
-func (m *hashmap) init(cap int) {
- m.m = make(map[string]*list, cap)
- m.n = cap
-}
-
-func (m *hashmap) Get(key string) *list {
- return m.m[key]
-}
-
-func (m *hashmap) Put(key string, list *list) {
- m.m[key] = list
- if n := len(m.m); n > m.n {
- m.n = n
- }
-}
-
-func (m *hashmap) Delete(key string) {
- delete(m.m, key)
-}
-
-func (m *hashmap) Compact() {
- // Noop when hashmap size
- // is too small to matter.
- if m.n < 2048 {
- return
- }
-
- // Difference between maximum map
- // size and the current map size.
- diff := m.n - len(m.m)
-
- // Maximum load factor before
- // runtime allocates new hmap:
- // maxLoad = 13 / 16
- //
- // So we apply the inverse/2, once
- // $maxLoad/2 % of hmap is empty we
- // compact the map to drop buckets.
- if 2*16*diff > m.n*13 {
-
- // Create new map only big as required.
- m2 := make(map[string]*list, len(m.m))
- for k, v := range m.m {
- m2[k] = v
- }
-
- // Set new.
- m.m = m2
- m.n = len(m2)
- }
-}