Skip to content

Commit 10582a9

Browse files
committed
core/vm: expose intpool to stack dup method
Improve the duplication method of the stack to reuse big ints by passing in an existing integer pool.
1 parent e16a7ef commit 10582a9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

core/vm/instructions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ func makePush(size uint64, pushByteSize int) executionFunc {
731731
// make push instruction function
732732
func makeDup(size int64) executionFunc {
733733
return func(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
734-
stack.dup(int(size))
734+
stack.dup(evm.interpreter.intPool, int(size))
735735
return nil, nil
736736
}
737737
}

core/vm/stack.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ func (st *Stack) swap(n int) {
6060
st.data[st.len()-n], st.data[st.len()-1] = st.data[st.len()-1], st.data[st.len()-n]
6161
}
6262

63-
func (st *Stack) dup(n int) {
64-
st.push(new(big.Int).Set(st.data[st.len()-n]))
63+
func (st *Stack) dup(pool *intPool, n int) {
64+
st.push(pool.get().Set(st.data[st.len()-n]))
6565
}
6666

6767
func (st *Stack) peek() *big.Int {

0 commit comments

Comments
 (0)