Commit c63b203c by DeltaBalances Committed by Francisco Giordano

Small SafeMath.sol gas improvements (add & mul). (#894)

parent c191757c
...@@ -10,11 +10,11 @@ library SafeMath { ...@@ -10,11 +10,11 @@ library SafeMath {
/** /**
* @dev Multiplies two numbers, throws on overflow. * @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) { if (a == 0) {
return 0; return 0;
} }
uint256 c = a * b; c = a * b;
assert(c / a == b); assert(c / a == b);
return c; return c;
} }
...@@ -40,8 +40,8 @@ library SafeMath { ...@@ -40,8 +40,8 @@ library SafeMath {
/** /**
* @dev Adds two numbers, throws on overflow. * @dev Adds two numbers, throws on overflow.
*/ */
function add(uint256 a, uint256 b) internal pure returns (uint256) { function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
uint256 c = a + b; c = a + b;
assert(c >= a); assert(c >= a);
return c; return c;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment