1
0
Fork 0
mirror of synced 2025-09-24 04:40:05 +00:00
This commit is contained in:
dark64 2023-03-06 13:37:12 +04:00
parent 3ce57d93a4
commit e8abfb51ea
11 changed files with 22 additions and 22 deletions

View file

@ -32,7 +32,7 @@ impl<'ast, T: Field> Folder<'ast, T> for Propagator<T> {
match e {
FlatExpression::Number(n) => FlatExpression::Number(n),
FlatExpression::Identifier(id) => match self.constants.get(&id) {
Some(c) => FlatExpression::Number(c.clone()),
Some(c) => FlatExpression::Number(*c),
None => FlatExpression::Identifier(id),
},
FlatExpression::Add(box e1, box e2) => {

View file

@ -517,7 +517,7 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Propagator<'ast, 'a, T> {
.unwrap()
{
FieldElementExpression::Number(num) => {
let mut acc = num.clone();
let mut acc = num;
let mut res = vec![];
for i in (0..bit_width as usize).rev() {

View file

@ -170,7 +170,7 @@ impl<'ast, T: Field> Folder<'ast, T> for UintOptimizer<'ast, T> {
left_max
.checked_add(&range_max.clone())
.map(|max| (false, true, max))
.unwrap_or_else(|| (true, true, range_max.clone() + range_max))
.unwrap_or_else(|| (true, true, range_max + range_max))
})
});
@ -223,7 +223,7 @@ impl<'ast, T: Field> Folder<'ast, T> for UintOptimizer<'ast, T> {
left_max
.checked_add(&target_offset)
.map(|max| (false, true, max))
.unwrap_or_else(|| (true, true, range_max.clone() + target_offset))
.unwrap_or_else(|| (true, true, range_max + target_offset))
} else {
left_max
.checked_add(&offset)
@ -294,7 +294,7 @@ impl<'ast, T: Field> Folder<'ast, T> for UintOptimizer<'ast, T> {
left_max
.checked_mul(&range_max.clone())
.map(|max| (false, true, max))
.unwrap_or_else(|| (true, true, range_max.clone() * range_max))
.unwrap_or_else(|| (true, true, range_max * range_max))
})
});

View file

@ -150,7 +150,7 @@ impl<'a, T: Field + ArkFieldExtensions, I: IntoIterator<Item = Statement<'a, T>>
self.program
.public_inputs_values(self.witness.as_ref().unwrap())
.iter()
.map(|v| v.clone().into_ark())
.map(|v| v.into_ark())
.collect()
}
}

View file

@ -36,7 +36,7 @@ pub fn flat_expression_from_variable_summands<T: Field>(v: &[(T, usize)]) -> Fla
match v.len() {
0 => FlatExpression::Number(T::zero()),
1 => {
let (val, var) = v[0].clone();
let (val, var) = v[0];
FlatExpression::Mult(
box FlatExpression::Number(val),
box FlatExpression::Identifier(Variable::new(var)),

View file

@ -164,8 +164,8 @@ impl<T: Field> LinComb<T> {
match acc.entry(val) {
Entry::Occupied(o) => {
// if the new value is non zero, update, else remove the term entirely
if o.get().clone() + coeff.clone() != T::zero() {
*o.into_mut() = o.get().clone() + coeff;
if *o.get() + coeff != T::zero() {
*o.into_mut() = *o.get() + coeff;
} else {
o.remove();
}

View file

@ -181,7 +181,7 @@ impl<'ast, T: Field, I: IntoIterator<Item = Statement<'ast, T>>> ProgIterator<'a
self.arguments
.iter()
.filter(|p| !p.private)
.map(|p| witness.0.get(&p.id).unwrap().clone())
.map(|p| *witness.0.get(&p.id).unwrap())
.chain(witness.return_values())
.collect()
}

View file

@ -43,7 +43,7 @@ impl<'ast, T: Field> std::ops::Sub for LinQuadComb<'ast, T> {
linear: {
let mut l = self.linear;
other.linear.iter_mut().for_each(|(c, _)| {
*c = T::zero() - &*c;
*c = T::zero() - *c;
});
l.append(&mut other.linear);
l
@ -51,7 +51,7 @@ impl<'ast, T: Field> std::ops::Sub for LinQuadComb<'ast, T> {
quadratic: {
let mut q = self.quadratic;
other.quadratic.iter_mut().for_each(|(c, _, _)| {
*c = T::zero() - &*c;
*c = T::zero() - *c;
});
q.append(&mut other.quadratic);
q
@ -68,18 +68,18 @@ impl<'ast, T: Field> LinQuadComb<'ast, T> {
}
Ok(Self {
constant: self.constant.clone() * rhs.constant.clone(),
constant: self.constant * rhs.constant,
linear: {
// lin0 * const1 + lin1 * const0
self.linear
.clone()
.into_iter()
.map(|(c, i)| (c * rhs.constant.clone(), i))
.map(|(c, i)| (c * rhs.constant, i))
.chain(
rhs.linear
.clone()
.into_iter()
.map(|(c, i)| (c * self.constant.clone(), i)),
.map(|(c, i)| (c * self.constant, i)),
)
.collect()
},
@ -87,16 +87,16 @@ impl<'ast, T: Field> LinQuadComb<'ast, T> {
// quad0 * const1 + quad1 * const0 + lin0 * lin1
self.quadratic
.into_iter()
.map(|(c, i0, i1)| (c * rhs.constant.clone(), i0, i1))
.map(|(c, i0, i1)| (c * rhs.constant, i0, i1))
.chain(
rhs.quadratic
.into_iter()
.map(|(c, i0, i1)| (c * self.constant.clone(), i0, i1)),
.map(|(c, i0, i1)| (c * self.constant, i0, i1)),
)
.chain(self.linear.iter().flat_map(|(cl, l)| {
rhs.linear
.iter()
.map(|(cr, r)| (cl.clone() * cr.clone(), l.clone(), r.clone()))
.map(|(cr, r)| (*cl * *cr, l.clone(), r.clone()))
}))
.collect()
},

View file

@ -189,7 +189,7 @@ impl<'a, T: BellmanFieldExtensions + Field, I: IntoIterator<Item = Statement<'a,
self.program
.public_inputs_values(self.witness.as_ref().unwrap())
.iter()
.map(|v| v.clone().into_bellman())
.map(|v| v.into_bellman())
.collect()
}

View file

@ -1885,7 +1885,7 @@ impl<'ast, T: Field> Flattener<'ast, T> {
// constants do not require directives
if let Some(FlatExpression::Number(ref x)) = e.field {
let bits: Vec<_> = Interpreter::execute_solver(&Solver::bits(to), &[x.clone()], &[])
let bits: Vec<_> = Interpreter::execute_solver(&Solver::bits(to), &[*x], &[])
.unwrap()
.into_iter()
.map(FlatExpression::Number)

View file

@ -50,7 +50,7 @@ impl Interpreter {
witness.insert(Variable::one(), T::one());
for (arg, value) in program.arguments.iter().zip(inputs.iter()) {
witness.insert(arg.id, value.clone());
witness.insert(arg.id, *value);
}
for statement in program.statements.into_iter() {
@ -188,7 +188,7 @@ impl Interpreter {
.map(|(a, v)| match &a.id._type {
zir::Type::FieldElement => Ok((
a.id.id.clone(),
zokrates_ast::zir::FieldElementExpression::Number(v.clone()).into(),
zokrates_ast::zir::FieldElementExpression::Number(*v).into(),
)),
zir::Type::Boolean => match v {
v if *v == T::from(0) => Ok((