You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/05 21:11:11 UTC

[GitHub] [arrow-rs] tustvold commented on a diff in pull request #3026: Make various i256 methods const

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


##########
arrow-buffer/src/bigint.rs:
##########
@@ -369,6 +373,20 @@ impl i256 {
     }
 }
 
+/// Temporary workaround due to lack of stable const array slicing
+/// See <https://github.com/rust-lang/rust/issues/90091>
+const fn split_array(vals: [u8; 32]) -> ([u8; 16], [u8; 16]) {
+    let mut a = [0; 16];
+    let mut b = [0; 16];
+    let mut i = 0;
+    while i != 16 {
+        a[i] = vals[i];
+        b[i] = vals[i + 16];
+        i += 1;
+    }
+    (a, b)
+}

Review Comment:
   Arrays are stack allocated, and in practice the compiler will optimise all of this away



-- 
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-unsubscribe@arrow.apache.org

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