Input check sequence modification for gas efficiency (#1043)

* Update StandardToken.sol

* Slight improvement in gas efficiency

Users tend to attempt to over-spend more than they attempt to burn non-burnable tokens. If the contract checks for overspending before assuring tokens are not being burnt a slight amount of gas might be saved in the long term.
This commit is contained in:
Lucas Gleba
2018-07-20 19:52:02 +02:00
committed by Nicolás Venturo
parent 67b67b791e
commit 1ecda54449
2 changed files with 2 additions and 2 deletions

View File

@ -29,8 +29,8 @@ contract BasicToken is ERC20Basic {
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
require(_to != address(0));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);

View File

@ -30,9 +30,9 @@ contract StandardToken is ERC20, BasicToken {
public
returns (bool)
{
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
require(_to != address(0));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);