Skip to content

Commit 084b3e2

Browse files
authored
refactor(zkm-lib): eliminate redundant clones (#422)
1 parent ac54012 commit 084b3e2

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

crates/zkvm/lib/src/utils.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,25 +86,23 @@ pub trait AffinePoint<const N: usize>: Clone + Sized {
8686
/// a_bits_le and b_bits_le should be in little endian order.
8787
fn multi_scalar_multiplication(
8888
a_bits_le: &[bool],
89-
a: Self,
89+
mut a: Self,
9090
b_bits_le: &[bool],
91-
b: Self,
91+
mut b: Self,
9292
) -> Self {
9393
// The length of the bit vectors must be the same.
9494
debug_assert!(a_bits_le.len() == b_bits_le.len());
9595

9696
let mut res: Self = Self::identity();
97-
let mut temp_a = a.clone();
98-
let mut temp_b = b.clone();
9997
for (a_bit, b_bit) in a_bits_le.iter().zip(b_bits_le.iter()) {
10098
if *a_bit {
101-
res.complete_add_assign(&temp_a);
99+
res.complete_add_assign(&a);
102100
}
103101
if *b_bit {
104-
res.complete_add_assign(&temp_b);
102+
res.complete_add_assign(&b);
105103
}
106-
temp_a.double();
107-
temp_b.double();
104+
a.double();
105+
b.double();
108106
}
109107
res
110108
}

0 commit comments

Comments
 (0)