mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-12 16:57:31 -06:00
add git.iim.gay/grufwub/go-store for storage backend, replacing blob.Storage
Signed-off-by: kim (grufwub) <grufwub@gmail.com>
This commit is contained in:
parent
ab32ce642b
commit
e43a46e982
89 changed files with 9372 additions and 240 deletions
32
vendor/git.iim.gay/grufwub/fastpath/pool.go
vendored
Normal file
32
vendor/git.iim.gay/grufwub/fastpath/pool.go
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package fastpath
|
||||
|
||||
import "sync"
|
||||
|
||||
// 1/8 max unix path length
|
||||
const defaultBufSize = 512
|
||||
|
||||
var (
|
||||
builderPool sync.Pool
|
||||
once = sync.Once{}
|
||||
)
|
||||
|
||||
func pool() *sync.Pool {
|
||||
once.Do(func() {
|
||||
builderPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
builder := NewBuilder(make([]byte, defaultBufSize))
|
||||
return &builder
|
||||
},
|
||||
}
|
||||
})
|
||||
return &builderPool
|
||||
}
|
||||
|
||||
func AcquireBuilder() *Builder {
|
||||
return pool().Get().(*Builder)
|
||||
}
|
||||
|
||||
func ReleaseBuilder(b *Builder) {
|
||||
b.Reset()
|
||||
pool().Put(b)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue