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

fix isPowerOf2() for gas optimization #28

Merged
merged 1 commit into from
Dec 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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