Skip to content

Commit

Permalink
more compiler assume
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleFU committed May 20, 2024
1 parent 2eb38e4 commit 064a328
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cpp/src/arrow/util/bit_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,17 @@ static constexpr bool GetBitFromByte(uint8_t byte, uint8_t i) {
}

static inline void ClearBit(uint8_t* bits, int64_t i) {
ARROW_COMPILER_ASSUME(i >= 0);
bits[i / 8] &= GetFlippedBitMask(i % 8);
}

static inline void SetBit(uint8_t* bits, int64_t i) { bits[i / 8] |= GetBitMask(i % 8); }
static inline void SetBit(uint8_t* bits, int64_t i) {
ARROW_COMPILER_ASSUME(i >= 0);
bits[i / 8] |= GetBitMask(i % 8);
}

static inline void SetBitTo(uint8_t* bits, int64_t i, bool bit_is_set) {
ARROW_COMPILER_ASSUME(i >= 0);
// https://graphics.stanford.edu/~seander/bithacks.html
// "Conditionally set or clear bits without branching"
// NOTE: this seems to confuse Valgrind as it reads from potentially
Expand Down

0 comments on commit 064a328

Please sign in to comment.