diff --git a/src/poly/evaluator.rs b/src/poly/evaluator.rs index 0bc17918..b74a2034 100644 --- a/src/poly/evaluator.rs +++ b/src/poly/evaluator.rs @@ -3,6 +3,7 @@ use std::{ hash::{Hash, Hasher}, marker::PhantomData, ops::{Add, Mul, MulAssign, Neg, Sub}, + sync::Arc, }; use group::ff::Field; @@ -241,15 +242,15 @@ impl Evaluator { /// accidentally construct this case directly, because it can only be implemented for the /// [`ExtendedLagrangeCoeff`] basis. #[derive(Clone, Debug)] -pub(crate) struct AstMul(Box>, Box>); +pub(crate) struct AstMul(Arc>, Arc>); /// A polynomial operation backed by an [`Evaluator`]. #[derive(Clone, Debug)] pub(crate) enum Ast { Poly(AstLeaf), - Add(Box>, Box>), + Add(Arc>, Arc>), Mul(AstMul), - Scale(Box>, F), + Scale(Arc>, F), /// The degree-1 term of a polynomial. /// /// The field element is the coeffient of the term in the standard basis, not the @@ -277,7 +278,7 @@ impl Neg for Ast { type Output = Ast; fn neg(self) -> Self::Output { - Ast::Scale(Box::new(self), -F::one()) + Ast::Scale(Arc::new(self), -F::one()) } } @@ -293,7 +294,7 @@ impl Add for Ast { type Output = Ast; fn add(self, other: Self) -> Self::Output { - Ast::Add(Box::new(self), Box::new(other)) + Ast::Add(Arc::new(self), Arc::new(other)) } } @@ -309,7 +310,7 @@ impl Add> for Ast { type Output = Ast; fn add(self, other: AstLeaf) -> Self::Output { - Ast::Add(Box::new(self), Box::new(other.into())) + Ast::Add(Arc::new(self), Arc::new(other.into())) } } @@ -341,7 +342,7 @@ impl Mul for Ast { type Output = Ast; fn mul(self, other: Self) -> Self::Output { - Ast::Mul(AstMul(Box::new(self), Box::new(other))) + Ast::Mul(AstMul(Arc::new(self), Arc::new(other))) } } @@ -357,7 +358,7 @@ impl Mul> for Ast { type Output = Ast; fn mul(self, other: AstLeaf) -> Self::Output { - Ast::Mul(AstMul(Box::new(self), Box::new(other.into()))) + Ast::Mul(AstMul(Arc::new(self), Arc::new(other.into()))) } } @@ -365,7 +366,7 @@ impl Mul for Ast { type Output = Ast; fn mul(self, other: Self) -> Self::Output { - Ast::Mul(AstMul(Box::new(self), Box::new(other))) + Ast::Mul(AstMul(Arc::new(self), Arc::new(other))) } } @@ -383,7 +384,7 @@ impl Mul> for Ast; fn mul(self, other: AstLeaf) -> Self::Output { - Ast::Mul(AstMul(Box::new(self), Box::new(other.into()))) + Ast::Mul(AstMul(Arc::new(self), Arc::new(other.into()))) } } @@ -391,7 +392,7 @@ impl Mul for Ast { type Output = Ast; fn mul(self, other: F) -> Self::Output { - Ast::Scale(Box::new(self), other) + Ast::Scale(Arc::new(self), other) } } @@ -399,7 +400,7 @@ impl Mul for &Ast { type Output = Ast; fn mul(self, other: F) -> Self::Output { - Ast::Scale(Box::new(self.clone()), other) + Ast::Scale(Arc::new(self.clone()), other) } }