tustvold commented on code in PR #4562:
URL: https://github.com/apache/arrow-rs/pull/4562#discussion_r1271311794


##########
arrow-cast/src/cast.rs:
##########
@@ -470,34 +461,19 @@ fn cast_interval_to_duration<D: ArrowTemporalType<Native 
= i64>>(
     };
 
     if cast_options.safe {
-        let iter = array.iter().map(|v| {
-            v.and_then(|v| {
-                let v = v / scale;
-                if v > i64::MAX as i128 {
-                    None
-                } else {
-                    Some(v as i64)
-                }
-            })
-        });
+        let iter = array
+            .iter()
+            .map(|v| v.and_then(|v| (v >> 64 == 0).then(|| (v as i64) / 
scale)));

Review Comment:
   As an added bonus we are now doing 64-bit division which should be cheaper 
than 128-bit



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to