mirror of
https://codeberg.org/superseriousbusiness/gotosocial.git
synced 2024-12-25 10:28:18 +03:00
27 lines
367 B
Go
27 lines
367 B
Go
|
package expr
|
||
|
|
||
|
import (
|
||
|
`sync`
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
expressionPool sync.Pool
|
||
|
)
|
||
|
|
||
|
func newExpression() *Expr {
|
||
|
if v := expressionPool.Get(); v == nil {
|
||
|
return new(Expr)
|
||
|
} else {
|
||
|
return resetExpression(v.(*Expr))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func freeExpression(p *Expr) {
|
||
|
expressionPool.Put(p)
|
||
|
}
|
||
|
|
||
|
func resetExpression(p *Expr) *Expr {
|
||
|
*p = Expr{}
|
||
|
return p
|
||
|
}
|