| 195 | /// guarantee that the range of bits to copy does not cover the whole range. |
| 196 | template <typename Uint, bool kAllowFullCopy = true> |
| 197 | [[nodiscard]] constexpr Uint CopyBitsInInteger(const CopyBitsParams<Uint>& params) { |
| 198 | constexpr auto kUintSizeBits = static_cast<int>(sizeof(Uint) * 8); |
| 199 | assert(params.start <= params.end); |
| 200 | assert(params.start < kUintSizeBits); |
| 201 | assert(params.end <= kUintSizeBits); |
| 202 | |
| 203 | const int length = params.end - params.start; |
| 204 | if constexpr (kAllowFullCopy) { |
| 205 | if (length == kUintSizeBits) { |
| 206 | return params.src; |
| 207 | } |
| 208 | } |
| 209 | assert(length < kUintSizeBits); |
| 210 | const Uint mask = |
| 211 | static_cast<Uint>(LeastSignificantBitMask<Uint, false>(length) << params.start); |
| 212 | return (~mask & params.dst) | (mask & params.src); |
| 213 | } |
| 214 | |
| 215 | static inline void ClearBit(uint8_t* bits, int64_t i) { |
| 216 | bits[i / 8] &= kFlippedBitmask[i % 8]; |
nothing calls this directly
no outgoing calls
no test coverage detected