Skip to content

Commit

Permalink
Merge pull request #171 from Rich-Harris/bitwise-operators
Browse files Browse the repository at this point in the history
more bitwise trickery
  • Loading branch information
Rich-Harris committed Jan 9, 2020
2 parents f0da066 + 9eea092 commit 4e1514f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/BitSet.js
Expand Up @@ -4,12 +4,10 @@ export default class BitSet {
}

add(n) {
this.bits[Math.floor(n / BITS)] |= 1 << n % BITS;
this.bits[n >> 5] |= 1 << (n & 31);
}

has(n) {
return !!(this.bits[Math.floor(n / BITS)] & (1 << n % BITS));
return !!(this.bits[n >> 5] & (1 << (n & 31)));
}
}

const BITS = 32;
}

0 comments on commit 4e1514f

Please sign in to comment.