Skip to content
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.

Commit

Permalink
fix isPowerOf2() for gas optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
osuketh committed Dec 4, 2018
1 parent 07b5d02 commit 727e00f
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions contracts/Verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,7 @@ contract VerifierContract {
}

function isPowerOf2(uint _x) internal pure returns (bool) {
if (_x % 2 == 0) {
return isPowerOf2(_x.div(2));
}

if (_x == 1) {
return true;
}

return false;
return _x != 0 && (_x & (_x - 1) == 0);
}

function getPseudorandomIndices(bytes32 _seed, uint _modulus, uint _count, uint _excludeMultiplesOf) internal returns (uint[] memory) {
Expand Down

0 comments on commit 727e00f

Please sign in to comment.