Ensure `bit_start` always ends up in [0, 8[, even when it starts negative.
| 60 | |
| 61 | /// Ensure `bit_start` always ends up in [0, 8[, even when it starts negative. |
| 62 | constexpr void Normalize() { |
| 63 | // On two's-complement targets an arithmetic right shift floors, and the AND mask |
| 64 | // yields the non-negative remainder (e.g. -1 -> byte -1, offset 7), unlike `/` and |
| 65 | // `%` which truncate toward zero. |
| 66 | data_ += bit_start_ >> 3; |
| 67 | bit_start_ &= 0b0111; |
| 68 | } |
| 69 | }; |
| 70 | |
| 71 | using BitmapSpanMut = BitmapSpan<uint8_t>; |