core/vm: optimize copy-less data retrievals
This commit is contained in:
@ -34,7 +34,21 @@ func calcMemSize(off, l *big.Int) *big.Int {
|
||||
|
||||
// getData returns a slice from the data based on the start and size and pads
|
||||
// up to size with zero's. This function is overflow safe.
|
||||
func getData(data []byte, start, size *big.Int) []byte {
|
||||
func getData(data []byte, start uint64, size uint64) []byte {
|
||||
length := uint64(len(data))
|
||||
if start > length {
|
||||
start = length
|
||||
}
|
||||
end := start + size
|
||||
if end > length {
|
||||
end = length
|
||||
}
|
||||
return common.RightPadBytes(data[start:end], int(size))
|
||||
}
|
||||
|
||||
// getDataBig returns a slice from the data based on the start and size and pads
|
||||
// up to size with zero's. This function is overflow safe.
|
||||
func getDataBig(data []byte, start *big.Int, size *big.Int) []byte {
|
||||
dlen := big.NewInt(int64(len(data)))
|
||||
|
||||
s := math.BigMin(start, dlen)
|
||||
|
Reference in New Issue
Block a user