Skip to content

Commit 69dec3f

Browse files
committed
Use ct_assign to avoid unnecessary cloning
1 parent 0a898b1 commit 69dec3f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/modular/div_by_2.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ pub(crate) mod boxed {
3636
pub(crate) fn div_by_2(a: &BoxedUint, modulus: &BoxedUint) -> BoxedUint {
3737
debug_assert_eq!(a.bits_precision(), modulus.bits_precision());
3838

39-
let (half, is_odd) = a.shr1_with_carry();
39+
let (mut half, is_odd) = a.shr1_with_carry();
4040
let half_modulus = modulus.shr1();
4141

4242
let if_odd = half
4343
.wrapping_add(&half_modulus)
4444
.wrapping_add(&BoxedUint::one_with_precision(a.bits_precision()));
4545

46-
BoxedUint::ct_select(&half, &if_odd, is_odd)
46+
half.ct_assign(&if_odd, is_odd);
47+
48+
half
4749
}
4850
}

0 commit comments

Comments
 (0)