Skip to content

Commit

Permalink
feat: use zip_eq for Polynomial add/sub (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpwang authored May 22, 2023
1 parent b38400a commit e24fa3c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions snark-verifier/src/util/poly.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Polynomial.

use crate::util::{arithmetic::Field, parallelize};
use itertools::Itertools;
use rand::Rng;
use std::{
iter::{self, Sum},
Expand Down Expand Up @@ -89,7 +90,7 @@ impl<'a, F: Field> Add<&'a Polynomial<F>> for Polynomial<F> {

fn add(mut self, rhs: &'a Polynomial<F>) -> Polynomial<F> {
parallelize(&mut self.0, |(lhs, start)| {
for (lhs, rhs) in lhs.iter_mut().zip(rhs.0[start..].iter()) {
for (lhs, rhs) in lhs.iter_mut().zip_eq(rhs.0[start..].iter()) {
*lhs += *rhs;
}
});
Expand All @@ -102,7 +103,7 @@ impl<'a, F: Field> Sub<&'a Polynomial<F>> for Polynomial<F> {

fn sub(mut self, rhs: &'a Polynomial<F>) -> Polynomial<F> {
parallelize(&mut self.0, |(lhs, start)| {
for (lhs, rhs) in lhs.iter_mut().zip(rhs.0[start..].iter()) {
for (lhs, rhs) in lhs.iter_mut().zip_eq(rhs.0[start..].iter()) {
*lhs -= *rhs;
}
});
Expand Down

0 comments on commit e24fa3c

Please sign in to comment.