diff options
Diffstat (limited to 'core/vm/evm/stack.go')
-rw-r--r-- | core/vm/evm/stack.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/core/vm/evm/stack.go b/core/vm/evm/stack.go new file mode 100644 index 000000000..4545201ce --- /dev/null +++ b/core/vm/evm/stack.go @@ -0,0 +1,24 @@ +package evm + +import ( + "math/big" + "sync" + + "github.com/dexon-foundation/dexon/core/vm" +) + +var stackPool = sync.Pool{ + New: func() interface{} { + return &vm.Stack{Data: make([]*big.Int, 0, 1024)} + }, +} + +func NewStack() *vm.Stack { + stack := stackPool.Get().(*vm.Stack) + stack.Data = stack.Data[:0] + return stack +} + +func Recyclestack(stack *vm.Stack) { + stackPool.Put(stack) +} |