Skip to content

Commit

Permalink
Use u32::reverse_bits to reverse bits (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram authored Jan 26, 2022
1 parent df0b41a commit fcbaf21
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,7 @@ fn test_ilog() {
}

fn bit_reverse(n :u32) -> u32 {
// From the stb_vorbis implementation
let mut nn = n;
nn = ((nn & 0xAAAAAAAA) >> 1) | ((nn & 0x55555555) << 1);
nn = ((nn & 0xCCCCCCCC) >> 2) | ((nn & 0x33333333) << 2);
nn = ((nn & 0xF0F0F0F0) >> 4) | ((nn & 0x0F0F0F0F) << 4);
nn = ((nn & 0xFF00FF00) >> 8) | ((nn & 0x00FF00FF) << 8);
return (nn >> 16) | (nn << 16);
n.reverse_bits()
}


Expand Down

0 comments on commit fcbaf21

Please sign in to comment.