summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-structr/index.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2025-04-07 11:03:57 +0100
committerLibravatar GitHub <noreply@github.com>2025-04-07 11:03:57 +0100
commit2cc5d6269d2ad3326c4ba4c6378fb0e9404646d0 (patch)
tree411267365a530a8911bc3e80c19de97b6bec843a /vendor/codeberg.org/gruf/go-structr/index.go
parent[bugfix] Change email `Date` header to use RFC2822 (#3972) (diff)
downloadgotosocial-2cc5d6269d2ad3326c4ba4c6378fb0e9404646d0.tar.xz
[chore]: Bump codeberg.org/gruf/go-structr from 0.9.0 to 0.9.6 (#3973)
Bumps codeberg.org/gruf/go-structr from 0.9.0 to 0.9.6. --- updated-dependencies: - dependency-name: codeberg.org/gruf/go-structr dependency-version: 0.9.6 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/codeberg.org/gruf/go-structr/index.go')
-rw-r--r--vendor/codeberg.org/gruf/go-structr/index.go37
1 files changed, 36 insertions, 1 deletions
diff --git a/vendor/codeberg.org/gruf/go-structr/index.go b/vendor/codeberg.org/gruf/go-structr/index.go
index eed2e4eea..23d3ffaee 100644
--- a/vendor/codeberg.org/gruf/go-structr/index.go
+++ b/vendor/codeberg.org/gruf/go-structr/index.go
@@ -1,6 +1,7 @@
package structr
import (
+ "os"
"reflect"
"strings"
"sync"
@@ -244,6 +245,39 @@ func (i *Index) key(buf *byteutil.Buffer, parts []unsafe.Pointer) string {
return string(buf.B)
}
+// add will attempt to add given index entry to appropriate
+// doubly-linked-list in index hashmap. in the case of an
+// existing entry in a "unique" index, it will return false.
+func (i *Index) add(key string, item *indexed_item) bool {
+ // Look for existing.
+ l := i.data.Get(key)
+
+ if l == nil {
+
+ // Allocate new.
+ l = new_list()
+ i.data.Put(key, l)
+
+ } else if is_unique(i.flags) {
+
+ // Collision!
+ return false
+ }
+
+ // Prepare new index entry.
+ entry := new_index_entry()
+ entry.item = item
+ entry.key = key
+ entry.index = i
+
+ // Add ourselves to item's index tracker.
+ item.indexed = append(item.indexed, entry)
+
+ // Add entry to index list.
+ l.push_front(&entry.elem)
+ return true
+}
+
// append will append the given index entry to appropriate
// doubly-linked-list in index hashmap. this handles case of
// overwriting "unique" index entries, and removes from given
@@ -403,7 +437,8 @@ func new_index_entry() *index_entry {
func free_index_entry(entry *index_entry) {
if entry.elem.next != nil ||
entry.elem.prev != nil {
- should_not_reach(false)
+ msg := assert("entry not in use")
+ os.Stderr.WriteString(msg + "\n")
return
}
entry.key = ""