3 ms·
You should be able to replace the pow(2, x) part with (1 << x), so e.g. getbit() becomes return (bits[n/8] & (1 << (n%8))) >> n%8; The compiler will turn
by pjscott 10y ago
You should be able to replace the pow(2, x) part with (1 << x), so e.g. getbit() becomes
return (bits[n/8] & (1 << (n%8))) >> n%8;
The compiler will turn the division and modulo into shifting and masking.
- deutronium 10y agoYeah that's a good point! Don't know why I didn't think about that.