github.com/consensys/gnark-crypto@v0.14.0/field/pool/pool.go (about) 1 package pool 2 3 import ( 4 "math/big" 5 "sync" 6 ) 7 8 // BigInt is a shared *big.Int memory pool 9 var BigInt bigIntPool 10 11 var _bigIntPool = sync.Pool{ 12 New: func() interface{} { 13 return new(big.Int) 14 }, 15 } 16 17 type bigIntPool struct{} 18 19 func (bigIntPool) Get() *big.Int { 20 return _bigIntPool.Get().(*big.Int) 21 } 22 23 func (bigIntPool) Put(v *big.Int) { 24 if v == nil { 25 return // see https://github.com/ConsenSys/gnark-crypto/issues/316 26 } 27 _bigIntPool.Put(v) 28 }