core/vm: improved push instructions
Improved push instructions by removing unnecessary big int allocations and by making it int instead of big.Int
This commit is contained in:
@ -706,10 +706,23 @@ func makeLog(size int) executionFunc {
|
||||
}
|
||||
|
||||
// make push instruction function
|
||||
func makePush(size uint64, bsize *big.Int) executionFunc {
|
||||
func makePush(size uint64, pushByteSize int) executionFunc {
|
||||
return func(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
||||
byts := getData(contract.Code, evm.interpreter.intPool.get().SetUint64(*pc+1), bsize)
|
||||
stack.push(new(big.Int).SetBytes(byts))
|
||||
codeLen := len(contract.Code)
|
||||
|
||||
startMin := codeLen
|
||||
if int(*pc+1) < startMin {
|
||||
startMin = int(*pc + 1)
|
||||
}
|
||||
|
||||
endMin := codeLen
|
||||
if startMin+pushByteSize < endMin {
|
||||
endMin = startMin + pushByteSize
|
||||
}
|
||||
|
||||
integer := evm.interpreter.intPool.get()
|
||||
stack.push(integer.SetBytes(common.RightPadBytes(contract.Code[startMin:endMin], pushByteSize)))
|
||||
|
||||
*pc += size
|
||||
return nil, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user