diff options
author | 2023-10-31 11:12:22 +0000 | |
---|---|---|
committer | 2023-10-31 11:12:22 +0000 | |
commit | ce71a5a7902963538fc54583588850563f6746cc (patch) | |
tree | 3e869eba6d25d2db5fe81184ffee595e451b3147 /vendor/codeberg.org/gruf/go-pools/henc.go | |
parent | [bugfix] Relax `Mention` parsing, allowing either href or name (#2320) (diff) | |
download | gotosocial-ce71a5a7902963538fc54583588850563f6746cc.tar.xz |
[feature] add per-uri dereferencer locks (#2291)
Diffstat (limited to 'vendor/codeberg.org/gruf/go-pools/henc.go')
-rw-r--r-- | vendor/codeberg.org/gruf/go-pools/henc.go | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/vendor/codeberg.org/gruf/go-pools/henc.go b/vendor/codeberg.org/gruf/go-pools/henc.go deleted file mode 100644 index cad905af4..000000000 --- a/vendor/codeberg.org/gruf/go-pools/henc.go +++ /dev/null @@ -1,46 +0,0 @@ -package pools - -import ( - "hash" - "sync" - - "codeberg.org/gruf/go-hashenc" -) - -// HashEncoderPool is a pooled allocator for hashenc.HashEncoder objects. -type HashEncoderPool interface { - // Get fetches a hashenc.HashEncoder from pool - Get() hashenc.HashEncoder - - // Put places supplied hashenc.HashEncoder back in pool - Put(hashenc.HashEncoder) -} - -// NewHashEncoderPool returns a newly instantiated hashenc.HashEncoder pool. -func NewHashEncoderPool(hash func() hash.Hash, enc func() hashenc.Encoder) HashEncoderPool { - return &hencPool{ - pool: sync.Pool{ - New: func() interface{} { - return hashenc.New(hash(), enc()) - }, - }, - size: hashenc.New(hash(), enc()).Size(), - } -} - -// hencPool is our implementation of HashEncoderPool. -type hencPool struct { - pool sync.Pool - size int -} - -func (p *hencPool) Get() hashenc.HashEncoder { - return p.pool.Get().(hashenc.HashEncoder) -} - -func (p *hencPool) Put(henc hashenc.HashEncoder) { - if henc.Size() < p.size { - return - } - p.pool.Put(henc) -} |