mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-30 23:52:46 +00:00
25 lines
379 B
Go
25 lines
379 B
Go
|
package internal
|
||
|
|
||
|
import (
|
||
|
"sync"
|
||
|
|
||
|
"codeberg.org/gruf/go-fastpath/v2"
|
||
|
)
|
||
|
|
||
|
var pathBuilderPool sync.Pool
|
||
|
|
||
|
func GetPathBuilder() *fastpath.Builder {
|
||
|
v := pathBuilderPool.Get()
|
||
|
if v == nil {
|
||
|
pb := new(fastpath.Builder)
|
||
|
pb.B = make([]byte, 0, 512)
|
||
|
v = pb
|
||
|
}
|
||
|
return v.(*fastpath.Builder)
|
||
|
}
|
||
|
|
||
|
func PutPathBuilder(pb *fastpath.Builder) {
|
||
|
pb.Reset()
|
||
|
pathBuilderPool.Put(pb)
|
||
|
}
|