FILE / ScuroNeko/mtg

mtglib/internal/obfuscated2/pools.go

Исходный файл и его история в репозитории.
FILE 4a2d1df384a19090a3f559aecd8a475383bd55e6
Files
mtg/mtglib/internal/obfuscated2/pools.go
T
9seconds 8de727932d Unpool handshake
Anyway, we are going to use stack here, no need for connection pooling.
Even arrays are allocaed on a stack because we do not use slices here
but real ones.
2021-03-18 22:06:52 +03:00

23 lines
319 B
Go

package obfuscated2
import (
"crypto/sha256"
"hash"
"sync"
)
var sha256HasherPool = sync.Pool{
New: func() interface{} {
return sha256.New()
},
}
func acquireSha256Hasher() hash.Hash {
return sha256HasherPool.Get().(hash.Hash)
}
func releaseSha256Hasher(h hash.Hash) {
h.Reset()
sha256HasherPool.Put(h)
}