diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-20 05:45:03 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-20 05:45:03 +0800 |
commit | df5901fdc58565448629a9bfd5ccecc1c5a5b349 (patch) | |
tree | f4365a7c84c098867cb97b684589ee17cd4b9309 /vm/common.go | |
parent | 013427bde27579d50010e728d9b59be91a7fb285 (diff) | |
download | dexon-df5901fdc58565448629a9bfd5ccecc1c5a5b349.tar dexon-df5901fdc58565448629a9bfd5ccecc1c5a5b349.tar.gz dexon-df5901fdc58565448629a9bfd5ccecc1c5a5b349.tar.bz2 dexon-df5901fdc58565448629a9bfd5ccecc1c5a5b349.tar.lz dexon-df5901fdc58565448629a9bfd5ccecc1c5a5b349.tar.xz dexon-df5901fdc58565448629a9bfd5ccecc1c5a5b349.tar.zst dexon-df5901fdc58565448629a9bfd5ccecc1c5a5b349.zip |
Removed more casts
Diffstat (limited to 'vm/common.go')
-rw-r--r-- | vm/common.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/vm/common.go b/vm/common.go index 5441a4ac5..8d8f4253f 100644 --- a/vm/common.go +++ b/vm/common.go @@ -73,9 +73,10 @@ func toValue(val *big.Int) interface{} { return val } -func getData(data []byte, start, size uint64) []byte { - x := uint64(math.Min(float64(start), float64(len(data)))) - y := uint64(math.Min(float64(x+size), float64(len(data)))) +func getData(data []byte, start, size *big.Int) []byte { + dlen := big.NewInt(int64(len(data))) - return common.RightPadBytes(data[x:y], int(size)) + s := common.BigMin(start, dlen) + e := common.BigMin(new(big.Int).Add(s, size), dlen) + return common.RightPadBytes(data[s.Uint64():e.Uint64()], int(size.Uint64())) } |