MCPcopy Create free account
hub / github.com/apache/kvrocks / SetBitTo

Function SetBitTo

src/common/bit_util.h:79–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77static constexpr bool GetBitFromByte(uint8_t byte, uint8_t i) { return byte & kBitmask[i]; }
78
79static 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
88namespace msb {

Callers 2

SetBitMethod · 0.85
SetBitMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected