Copilot commented on code in PR #50785:
URL: https://github.com/apache/arrow/pull/50785#discussion_r3704450305


##########
cpp/src/arrow/util/bitmap_ops.cc:
##########
@@ -123,28 +123,40 @@ uint8_t GetReversedBlock(uint8_t block_left, uint8_t 
block_right, uint8_t length
   return ReverseUint8(((block_right << 8) + block_left) >> length);
 }
 
+template <TransferMode mode>
+void TransferReaderWriter(auto&& reader, auto&& writer) {
+  auto nwords = reader.words();
+  while (nwords--) {
+    auto word = reader.NextWord();
+    writer.PutNextWord(mode == TransferMode::Invert ? ~word : word);
+  }
+  auto nbytes = reader.trailing_bytes();
+  while (nbytes--) {
+    int valid_bits;
+    auto byte = reader.NextTrailingByte(valid_bits);
+    writer.PutNextTrailingByte(mode == TransferMode::Invert ? ~byte : byte, 
valid_bits);
+  }
+}
+
 template <TransferMode mode>
 void TransferBitmap(const uint8_t* data, int64_t offset, int64_t length,
                     int64_t dest_offset, uint8_t* dest) {
   int64_t bit_offset = offset % 8;
   int64_t dest_bit_offset = dest_offset % 8;
 
-  if (bit_offset || dest_bit_offset) {
+  if (length == 0) {
+    return;
+  } else if (dest_bit_offset) {
+    const auto count = std::min(8 - dest_bit_offset, length);

Review Comment:
   `std::min` is used here, but this file doesn’t include `<algorithm>`. 
Relying on transitive includes can break builds when headers change. Either add 
`<algorithm>` at the top of this file, or avoid `std::min` here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to