Commit 1ecda544 by Lucas Gleba Committed by Nicolás Venturo

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.
parent 67b67b79
...@@ -29,8 +29,8 @@ contract BasicToken is ERC20Basic { ...@@ -29,8 +29,8 @@ contract BasicToken is ERC20Basic {
* @param _value The amount to be transferred. * @param _value The amount to be transferred.
*/ */
function transfer(address _to, uint256 _value) public returns (bool) { function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]); require(_value <= balances[msg.sender]);
require(_to != address(0));
balances[msg.sender] = balances[msg.sender].sub(_value); balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value); balances[_to] = balances[_to].add(_value);
......
...@@ -30,9 +30,9 @@ contract StandardToken is ERC20, BasicToken { ...@@ -30,9 +30,9 @@ contract StandardToken is ERC20, BasicToken {
public public
returns (bool) returns (bool)
{ {
require(_to != address(0));
require(_value <= balances[_from]); require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]); require(_value <= allowed[_from][msg.sender]);
require(_to != address(0));
balances[_from] = balances[_from].sub(_value); balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value); balances[_to] = balances[_to].add(_value);
......
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