mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-01 01:42:25 -05:00
update dependencies (#296)
This commit is contained in:
parent
2aaec82732
commit
829a934d23
124 changed files with 2453 additions and 1588 deletions
46
vendor/codeberg.org/gruf/go-pools/fastpath.go
generated
vendored
Normal file
46
vendor/codeberg.org/gruf/go-pools/fastpath.go
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package pools
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"codeberg.org/gruf/go-fastpath"
|
||||
)
|
||||
|
||||
// PathBuilderPool is a pooled allocator for fastpath.Builder objects
|
||||
type PathBuilderPool interface {
|
||||
// Get fetches a fastpath.Builder from pool
|
||||
Get() *fastpath.Builder
|
||||
|
||||
// Put places supplied fastpath.Builder back in pool
|
||||
Put(*fastpath.Builder)
|
||||
}
|
||||
|
||||
// NewPathBuilderPool returns a newly instantiated fastpath.Builder pool
|
||||
func NewPathBuilderPool(size int) PathBuilderPool {
|
||||
return &pathBuilderPool{
|
||||
pool: sync.Pool{
|
||||
New: func() interface{} {
|
||||
return &fastpath.Builder{B: make([]byte, 0, size)}
|
||||
},
|
||||
},
|
||||
size: size,
|
||||
}
|
||||
}
|
||||
|
||||
// pathBuilderPool is our implementation of PathBuilderPool
|
||||
type pathBuilderPool struct {
|
||||
pool sync.Pool
|
||||
size int
|
||||
}
|
||||
|
||||
func (p *pathBuilderPool) Get() *fastpath.Builder {
|
||||
return p.pool.Get().(*fastpath.Builder)
|
||||
}
|
||||
|
||||
func (p *pathBuilderPool) Put(pb *fastpath.Builder) {
|
||||
if pb.Cap() < p.size {
|
||||
return
|
||||
}
|
||||
pb.Reset()
|
||||
p.pool.Put(pb)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue