Jefffrey commented on code in PR #5417:
URL: https://github.com/apache/arrow-rs/pull/5417#discussion_r1499908823


##########
arrow-buffer/src/util/bit_util.rs:
##########
@@ -39,7 +39,12 @@ pub fn round_upto_multiple_of_64(num: usize) -> usize {
 /// be a power of 2.
 pub fn round_upto_power_of_2(num: usize, factor: usize) -> usize {
     debug_assert!(factor > 0 && (factor & (factor - 1)) == 0);
-    (num + (factor - 1)) & !(factor - 1)
+    let rounded = (num.saturating_add(factor - 1)) & !(factor - 1);

Review Comment:
   Yeah this makes sense, thanks will try it out :+1: 



-- 
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