| 77 | static constexpr bool GetBitFromByte(uint8_t byte, uint8_t i) { return byte & kBitmask[i]; } |
| 78 | |
| 79 | static inline void SetBitTo(uint8_t *bits, int64_t i, bool bit_is_set) { |
| 80 | // https://graphics.stanford.edu/~seander/bithacks.html |
| 81 | // "Conditionally set or clear bits without branching" |
| 82 | // NOTE: this seems to confuse Valgrind as it reads from potentially |
| 83 | // uninitialized memory |
| 84 | bits[i / 8] ^= static_cast<uint8_t>(-static_cast<uint8_t>(bit_is_set) ^ bits[i / 8]) & kBitmask[i % 8]; |
| 85 | } |
| 86 | } // namespace lsb |
| 87 | |
| 88 | namespace msb { |