Small SafeMath.sol gas improvements (add & mul). (#894)
This commit is contained in:
committed by
Francisco Giordano
parent
c191757c6e
commit
c63b203c1d
@ -10,11 +10,11 @@ library SafeMath {
|
||||
/**
|
||||
* @dev Multiplies two numbers, throws on overflow.
|
||||
*/
|
||||
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
||||
if (a == 0) {
|
||||
return 0;
|
||||
}
|
||||
uint256 c = a * b;
|
||||
c = a * b;
|
||||
assert(c / a == b);
|
||||
return c;
|
||||
}
|
||||
@ -40,8 +40,8 @@ library SafeMath {
|
||||
/**
|
||||
* @dev Adds two numbers, throws on overflow.
|
||||
*/
|
||||
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
uint256 c = a + b;
|
||||
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
|
||||
c = a + b;
|
||||
assert(c >= a);
|
||||
return c;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user