vkonst / ctd-token

Smart-contracts for Cointed Token and Token Sale
11 stars 9 forks source link

Redudant lines of code in Create() #8

Closed 08xmt closed 6 years ago

08xmt commented 6 years ago

The lines:

122: uint256 newTokens = weiToParticipate.mul(rates.total); 123: uint256 requestedSupply = totalSupply.add(newTokens);

And

130: newTokens = weiToParticipate.mul(rates.total); 131: requestedSupply = totalSupply.add(newTokens);

are slightly redundant. By moving lines 122 and 123 to after the if statement started in line 128, a slight amount of gas can be saved on execution and deployment.

vkonst commented 6 years ago

Not an issue

weiToPaticipate depends on requestedSupply and hence on newTokes. On the other hand, if weiToParticipate is not 0, then the requestedSupply and newTokes must be recalculated.

Therefore these lines can not be moved bellow the if statement.

Thank you for your input.