summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-pools/fastpath.go
diff options
context:
space:
mode:
authorLibravatar Terin Stock <terinjokes@gmail.com>2022-04-26 20:30:25 -0700
committerLibravatar Terin Stock <terinjokes@gmail.com>2023-01-31 15:16:42 +0100
commit83b4c9ebc87d0fddf4e638f13e3af1483912e3a5 (patch)
tree47840b84c0fd3cb226eab2ecb3dbce0617163406 /vendor/codeberg.org/gruf/go-pools/fastpath.go
parent[chore] update URLs to forked source (diff)
downloadgotosocial-83b4c9ebc87d0fddf4e638f13e3af1483912e3a5.tar.xz
[chore] remove vendor
Diffstat (limited to 'vendor/codeberg.org/gruf/go-pools/fastpath.go')
-rw-r--r--vendor/codeberg.org/gruf/go-pools/fastpath.go46
1 files changed, 0 insertions, 46 deletions
diff --git a/vendor/codeberg.org/gruf/go-pools/fastpath.go b/vendor/codeberg.org/gruf/go-pools/fastpath.go
deleted file mode 100644
index eb76f03e4..000000000
--- a/vendor/codeberg.org/gruf/go-pools/fastpath.go
+++ /dev/null
@@ -1,46 +0,0 @@
-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)
-}