Skip to content

Commit e39a073

Browse files
committed
Use unpack<uint16_t> in BitReader
1 parent 03a4558 commit e39a073

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

cpp/src/arrow/util/bit_stream_utils_internal.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -323,19 +323,10 @@ inline int BitReader::GetBatch(int num_bits, T* v, int batch_size) {
323323
}
324324
}
325325

326-
if (sizeof(T) == 4) {
327-
int num_unpacked =
328-
internal::unpack(buffer + byte_offset, reinterpret_cast<uint32_t*>(v + i),
329-
batch_size - i, num_bits);
330-
i += num_unpacked;
331-
byte_offset += num_unpacked * num_bits / 8;
332-
} else if (sizeof(T) == 8 && num_bits > 32) {
333-
// Use unpack64 only if num_bits is larger than 32
334-
// TODO (ARROW-13677): improve the performance of internal::unpack64
335-
// and remove the restriction of num_bits
336-
int num_unpacked =
337-
internal::unpack(buffer + byte_offset, reinterpret_cast<uint64_t*>(v + i),
338-
batch_size - i, num_bits);
326+
if constexpr (sizeof(T) >= 2) {
327+
int num_unpacked = internal::unpack(buffer + byte_offset,
328+
reinterpret_cast<std::make_unsigned_t<T>*>(v + i),
329+
batch_size - i, num_bits);
339330
i += num_unpacked;
340331
byte_offset += num_unpacked * num_bits / 8;
341332
} else {

0 commit comments

Comments
 (0)