mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-23 18:52:11 +00:00
6f4ae8f58d
Signed-off-by: kim <grufwub@gmail.com>
26 lines
456 B
Go
26 lines
456 B
Go
package result
|
|
|
|
import "sync"
|
|
|
|
// resultPool is a global pool for result
|
|
// objects, regardless of cache type.
|
|
var resultPool sync.Pool
|
|
|
|
// getEntry fetches a result from pool, or allocates new.
|
|
func getResult() *result {
|
|
v := resultPool.Get()
|
|
if v == nil {
|
|
return new(result)
|
|
}
|
|
return v.(*result)
|
|
}
|
|
|
|
// putResult replaces a result in the pool.
|
|
func putResult(r *result) {
|
|
r.PKey = 0
|
|
r.Keys = nil
|
|
r.Value = nil
|
|
r.Error = nil
|
|
resultPool.Put(r)
|
|
}
|