mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[chore] update go-structr => v0.6.2 (fixes nested field ptr following) (#2822)
* update go-structr => v0.6.1 (fixes nested field ptr following) * bump to v0.6.2
This commit is contained in:
25
vendor/codeberg.org/gruf/go-structr/cache.go
generated
vendored
25
vendor/codeberg.org/gruf/go-structr/cache.go
generated
vendored
@ -255,18 +255,21 @@ func (c *Cache[T]) LoadOne(index *Index, key Key, load func() (T, error)) (T, er
|
||||
item := index.get_one(key)
|
||||
|
||||
if ok = (item != nil); ok {
|
||||
if value, is := item.data.(T); is {
|
||||
var is bool
|
||||
|
||||
if val, is = item.data.(T); is {
|
||||
// Set value COPY.
|
||||
val = c.copy(value)
|
||||
val = c.copy(val)
|
||||
|
||||
// Push to front of LRU list, USING
|
||||
// THE ITEM'S LRU ENTRY, NOT THE
|
||||
// INDEX KEY ENTRY. VERY IMPORTANT!!
|
||||
c.lru.move_front(&item.elem)
|
||||
|
||||
} else if error, is := item.data.(error); is {
|
||||
// Return error.
|
||||
err = error
|
||||
} else {
|
||||
|
||||
// Attempt to return error.
|
||||
err, _ = item.data.(error)
|
||||
}
|
||||
}
|
||||
|
||||
@ -423,10 +426,10 @@ func (c *Cache[T]) Invalidate(index *Index, keys ...Key) {
|
||||
// Preallocate expected ret slice.
|
||||
values := make([]T, 0, len(keys))
|
||||
|
||||
for i := range keys {
|
||||
for _, key := range keys {
|
||||
// Delete all items under key from index, collecting
|
||||
// value items and dropping them from all their indices.
|
||||
index.delete(keys[i], func(item *indexed_item) {
|
||||
index.delete(key, func(item *indexed_item) {
|
||||
|
||||
if value, ok := item.data.(T); ok {
|
||||
// No need to copy, as item
|
||||
@ -524,6 +527,9 @@ func (c *Cache[T]) store_value(index *Index, key Key, value T) {
|
||||
index.append(key, item)
|
||||
}
|
||||
|
||||
// Get ptr to value data.
|
||||
ptr := unsafe.Pointer(&value)
|
||||
|
||||
// Acquire key buf.
|
||||
buf := new_buffer()
|
||||
|
||||
@ -538,7 +544,10 @@ func (c *Cache[T]) store_value(index *Index, key Key, value T) {
|
||||
}
|
||||
|
||||
// Extract fields comprising index key.
|
||||
parts := extract_fields(value, idx.fields)
|
||||
parts := extract_fields(ptr, idx.fields)
|
||||
if parts == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
// Calculate index key.
|
||||
key := idx.key(buf, parts)
|
||||
|
Reference in New Issue
Block a user