improve mum performance and reduce gas cost

This commit is contained in:
Chen Yi-Cyuan
2017-10-30 09:58:52 +08:00
parent 39d6c92069
commit 5ad07e1892

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;
}