mirror of https://github.com/zcash/orchard.git
Optimize transpose_option_array
This commit is contained in:
parent
8dfcd7d49b
commit
cbded2b821
|
@ -3,7 +3,7 @@ use halo2::{
|
||||||
plonk::{Advice, Column, Error, Permutation},
|
plonk::{Advice, Column, Error, Permutation},
|
||||||
};
|
};
|
||||||
use pasta_curves::arithmetic::FieldExt;
|
use pasta_curves::arithmetic::FieldExt;
|
||||||
use std::convert::TryInto;
|
use std::array;
|
||||||
|
|
||||||
pub(crate) mod cond_swap;
|
pub(crate) mod cond_swap;
|
||||||
pub(crate) mod enable_flag;
|
pub(crate) mod enable_flag;
|
||||||
|
@ -89,13 +89,11 @@ where
|
||||||
pub fn transpose_option_array<T: Copy + std::fmt::Debug, const LEN: usize>(
|
pub fn transpose_option_array<T: Copy + std::fmt::Debug, const LEN: usize>(
|
||||||
option_array: Option<[T; LEN]>,
|
option_array: Option<[T; LEN]>,
|
||||||
) -> [Option<T>; LEN] {
|
) -> [Option<T>; LEN] {
|
||||||
|
let mut ret = [None; LEN];
|
||||||
if let Some(arr) = option_array {
|
if let Some(arr) = option_array {
|
||||||
arr.iter()
|
for (entry, value) in ret.iter_mut().zip(array::IntoIter::new(arr)) {
|
||||||
.map(|el| Some(*el))
|
*entry = Some(value);
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.try_into()
|
|
||||||
.unwrap()
|
|
||||||
} else {
|
|
||||||
[None; LEN]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue