Skip to content

Commit

Permalink
Simplify AsnDecoder.ReverseBitsPerByte (#75301)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub authored Sep 9, 2022
1 parent 253aea6 commit e380cab
Showing 1 changed file with 1 addition and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -394,16 +394,7 @@ internal static void ReverseBitsPerByte(Span<byte> value)
{
for (int byteIdx = 0; byteIdx < value.Length; byteIdx++)
{
byte cur = value[byteIdx];
byte mask = 0b1000_0000;
byte next = 0;

for (; cur != 0; cur >>= 1, mask >>= 1)
{
next |= (byte)((cur & 1) * mask);
}

value[byteIdx] = next;
value[byteIdx] = (byte)((value[byteIdx] * 0x0202020202ul & 0x010884422010ul) % 1023);
}
}
}
Expand Down

0 comments on commit e380cab

Please sign in to comment.