core/vm: capped int pool
This commit is contained in:
parent
a816e75662
commit
e16a7ef60f
@ -20,6 +20,8 @@ import "math/big"
|
|||||||
|
|
||||||
var checkVal = big.NewInt(-42)
|
var checkVal = big.NewInt(-42)
|
||||||
|
|
||||||
|
const poolLimit = 256
|
||||||
|
|
||||||
// intPool is a pool of big integers that
|
// intPool is a pool of big integers that
|
||||||
// can be reused for all big.Int operations.
|
// can be reused for all big.Int operations.
|
||||||
type intPool struct {
|
type intPool struct {
|
||||||
@ -37,6 +39,10 @@ func (p *intPool) get() *big.Int {
|
|||||||
return new(big.Int)
|
return new(big.Int)
|
||||||
}
|
}
|
||||||
func (p *intPool) put(is ...*big.Int) {
|
func (p *intPool) put(is ...*big.Int) {
|
||||||
|
if len(p.pool.data) > poolLimit {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for _, i := range is {
|
for _, i := range is {
|
||||||
// verifyPool is a build flag. Pool verification makes sure the integrity
|
// verifyPool is a build flag. Pool verification makes sure the integrity
|
||||||
// of the integer pool by comparing values to a default value.
|
// of the integer pool by comparing values to a default value.
|
||||||
|
Loading…
Reference in New Issue
Block a user