Skip to content

Commit 7f736fb

Browse files
committed
:
1 parent 7c3480e commit 7f736fb

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

cpp/src/arrow/util/bit_util.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,8 @@ constexpr int64_t CoveringBytes(int64_t offset, int64_t length) {
167167

168168
// Returns the 'num_bits' least-significant bits of 'v'.
169169
static inline uint64_t TrailingBits(uint64_t v, int num_bits) {
170-
if (ARROW_PREDICT_FALSE(num_bits == 0)) return 0;
171170
if (ARROW_PREDICT_FALSE(num_bits >= 64)) return v;
172-
int n = 64 - num_bits;
173-
return (v << n) >> n;
171+
return ((v >> num_bits) << num_bits) ^ v;
174172
}
175173

176174
/// \brief Count the number of leading zeros in an unsigned integer.

0 commit comments

Comments
 (0)