mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
update go-ffmpreg to v0.3.1 (pulls in latest wazero too) (#3398)
This commit is contained in:
40
vendor/github.com/tetratelabs/wazero/internal/descriptor/table.go
generated
vendored
40
vendor/github.com/tetratelabs/wazero/internal/descriptor/table.go
generated
vendored
@ -1,6 +1,9 @@
|
||||
package descriptor
|
||||
|
||||
import "math/bits"
|
||||
import (
|
||||
"math/bits"
|
||||
"slices"
|
||||
)
|
||||
|
||||
// Table is a data structure mapping 32 bit descriptor to items.
|
||||
//
|
||||
@ -37,23 +40,13 @@ func (t *Table[Key, Item]) Len() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
// grow ensures that t has enough room for n items, potentially reallocating the
|
||||
// internal buffers if their capacity was too small to hold this many items.
|
||||
// grow grows the table by n * 64 items.
|
||||
func (t *Table[Key, Item]) grow(n int) {
|
||||
// Round up to a multiple of 64 since this is the smallest increment due to
|
||||
// using 64 bits masks.
|
||||
n = (n*64 + 63) / 64
|
||||
total := len(t.masks) + n
|
||||
t.masks = slices.Grow(t.masks, n)[:total]
|
||||
|
||||
if n > len(t.masks) {
|
||||
masks := make([]uint64, n)
|
||||
copy(masks, t.masks)
|
||||
|
||||
items := make([]Item, n*64)
|
||||
copy(items, t.items)
|
||||
|
||||
t.masks = masks
|
||||
t.items = items
|
||||
}
|
||||
total = len(t.items) + n*64
|
||||
t.items = slices.Grow(t.items, n*64)[:total]
|
||||
}
|
||||
|
||||
// Insert inserts the given item to the table, returning the key that it is
|
||||
@ -78,13 +71,9 @@ insert:
|
||||
}
|
||||
}
|
||||
|
||||
// No free slot found, grow the table and retry.
|
||||
offset = len(t.masks)
|
||||
n := 2 * len(t.masks)
|
||||
if n == 0 {
|
||||
n = 1
|
||||
}
|
||||
|
||||
t.grow(n)
|
||||
t.grow(1)
|
||||
goto insert
|
||||
}
|
||||
|
||||
@ -109,10 +98,10 @@ func (t *Table[Key, Item]) InsertAt(item Item, key Key) bool {
|
||||
if key < 0 {
|
||||
return false
|
||||
}
|
||||
if diff := int(key) - t.Len(); diff > 0 {
|
||||
index := uint(key) / 64
|
||||
if diff := int(index) - len(t.masks) + 1; diff > 0 {
|
||||
t.grow(diff)
|
||||
}
|
||||
index := uint(key) / 64
|
||||
shift := uint(key) % 64
|
||||
t.masks[index] |= 1 << shift
|
||||
t.items[key] = item
|
||||
@ -124,7 +113,8 @@ func (t *Table[Key, Item]) Delete(key Key) {
|
||||
if key < 0 { // invalid key
|
||||
return
|
||||
}
|
||||
if index, shift := key/64, key%64; int(index) < len(t.masks) {
|
||||
if index := uint(key) / 64; int(index) < len(t.masks) {
|
||||
shift := uint(key) % 64
|
||||
mask := t.masks[index]
|
||||
if (mask & (1 << shift)) != 0 {
|
||||
var zero Item
|
||||
|
Reference in New Issue
Block a user