refactor: avoid if-condition based on bit value

This commit is contained in:
Lukas Lihotzki 2021-04-26 18:48:54 +02:00
parent b4f755388a
commit fdf650abd5
1 changed files with 1 additions and 3 deletions

View File

@ -84,9 +84,7 @@ List<int> _bytesToInt(Uint8List bytes, int totalBits) {
for (final byte in bytes) {
for (final bit in [7, 6, 5, 4, 3, 2, 1, 0]) {
numBits++;
if ((byte & (1 << bit)) > 0) {
current += 1 << (totalBits - numBits);
}
current |= ((byte >> bit) & 1) << (totalBits - numBits);
if (numBits >= totalBits) {
ret.add(current);
current = 0;