Merge pull request #522 from emn178/feature/improve_mul

improve mul performance and reduce gas cost
This commit is contained in:
Santiago Palladino
2017-11-14 17:49:09 -03:00
committed by GitHub

View File

@ -7,8 +7,11 @@ pragma solidity ^0.4.11;
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(a == 0 || c / a == b);
assert(c / a == b);
return c;
}