From 8b309fef41f08f92620d5af1b0c3e632ac54e313 Mon Sep 17 00:00:00 2001 From: Daniel Lubarov Date: Mon, 10 May 2021 14:30:18 -0700 Subject: [PATCH] Tweak --- src/polynomial/polynomial.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/polynomial/polynomial.rs b/src/polynomial/polynomial.rs index a0cdeb8b..86cba130 100644 --- a/src/polynomial/polynomial.rs +++ b/src/polynomial/polynomial.rs @@ -160,11 +160,9 @@ impl Add for &PolynomialCoeffs { fn add(self, rhs: Self) -> Self::Output { let len = max(self.len(), rhs.len()); - let mut coeffs = self.coeffs.clone(); - coeffs.resize(len, F::ZERO); - for (i, &c) in rhs.coeffs.iter().enumerate() { - coeffs[i] += c; - } + let a = self.padded(len).coeffs; + let b = rhs.padded(len).coeffs; + let coeffs = a.into_iter().zip(b).map(|(x, y)| x + y).collect(); PolynomialCoeffs::new(coeffs) } }