mirror of
https://github.com/arnaucube/ark-r1cs-std.git
synced 2026-01-10 16:01:28 +01:00
Remove a few unnecessary .into_iter() explicit calls, and some cloning.
See https://rust-lang.github.io/rust-clippy/master/#explicit_into_iter_loop
This commit is contained in:
committed by
Pratyush Mishra
parent
581f3df55f
commit
10c6e85c1a
@@ -371,7 +371,7 @@ impl Boolean {
|
||||
values: &[u8],
|
||||
) -> Vec<Self> {
|
||||
let mut input_bits = vec![];
|
||||
for (byte_i, input_byte) in values.into_iter().enumerate() {
|
||||
for (byte_i, input_byte) in values.iter().enumerate() {
|
||||
for bit_i in (0..8).rev() {
|
||||
let cs = cs.ns(|| format!("input_bit_gadget {} {}", byte_i, bit_i));
|
||||
input_bits.push(
|
||||
|
||||
@@ -291,7 +291,7 @@ impl<ConstraintF: Field> ToBytesGadget<ConstraintF> for UInt32 {
|
||||
None => [None, None, None, None],
|
||||
};
|
||||
let mut bytes = Vec::new();
|
||||
for (i, chunk8) in self.to_bits_le().chunks(8).into_iter().enumerate() {
|
||||
for (i, chunk8) in self.to_bits_le().chunks(8).enumerate() {
|
||||
let byte = UInt8 {
|
||||
bits: chunk8.to_vec(),
|
||||
value: value_chunks[i],
|
||||
|
||||
@@ -60,7 +60,7 @@ impl UInt8 {
|
||||
T: Into<Option<u8>> + Copy,
|
||||
{
|
||||
let mut output_vec = Vec::with_capacity(values.len());
|
||||
for (i, value) in values.into_iter().enumerate() {
|
||||
for (i, value) in values.iter().enumerate() {
|
||||
let byte: Option<u8> = Into::into(*value);
|
||||
let alloc_byte = Self::alloc(&mut cs.ns(|| format!("byte_{}", i)), || byte.get())?;
|
||||
output_vec.push(alloc_byte);
|
||||
@@ -115,7 +115,7 @@ impl UInt8 {
|
||||
/// LSB-first means that we can easily get the corresponding field element
|
||||
/// via double and add.
|
||||
pub fn into_bits_le(&self) -> Vec<Boolean> {
|
||||
self.bits.iter().cloned().collect()
|
||||
self.bits.to_vec()
|
||||
}
|
||||
|
||||
/// Converts a little-endian byte order representation of bits into a
|
||||
@@ -317,7 +317,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_uint8_alloc_input_vec() {
|
||||
let mut cs = TestConstraintSystem::<Fr>::new();
|
||||
let byte_vals = (64u8..128u8).into_iter().collect::<Vec<_>>();
|
||||
let byte_vals = (64u8..128u8).collect::<Vec<_>>();
|
||||
let bytes = UInt8::alloc_input_vec(cs.ns(|| "alloc value"), &byte_vals).unwrap();
|
||||
for (native_byte, gadget_byte) in byte_vals.into_iter().zip(bytes) {
|
||||
let bits = gadget_byte.into_bits_le();
|
||||
|
||||
@@ -217,7 +217,7 @@ pub trait FieldGadget<F: Field, ConstraintF: Field>:
|
||||
bits: &[Boolean],
|
||||
) -> Result<Self, SynthesisError> {
|
||||
let mut res = Self::one(cs.ns(|| "Alloc result"))?;
|
||||
for (i, bit) in bits.into_iter().enumerate() {
|
||||
for (i, bit) in bits.iter().enumerate() {
|
||||
res = res.square(cs.ns(|| format!("Double {}", i)))?;
|
||||
let tmp = res.mul(cs.ns(|| format!("Add {}-th base power", i)), self)?;
|
||||
res = Self::conditionally_select(
|
||||
|
||||
@@ -983,11 +983,11 @@ mod projective_impl {
|
||||
|
||||
// Compute ∏(h_i^{m_i}) for all i.
|
||||
for (segment_i, (segment_bits_chunks, segment_powers)) in
|
||||
scalars.into_iter().zip(bases.iter()).enumerate()
|
||||
scalars.iter().zip(bases.iter()).enumerate()
|
||||
{
|
||||
for (i, (bits, base_power)) in segment_bits_chunks
|
||||
.borrow()
|
||||
.into_iter()
|
||||
.iter()
|
||||
.zip(segment_powers.borrow().iter())
|
||||
.enumerate()
|
||||
{
|
||||
|
||||
@@ -102,7 +102,7 @@ where
|
||||
qs: &[Self::G2PreparedGadget],
|
||||
) -> Result<Self::GTGadget, SynthesisError> {
|
||||
let mut pairs = vec![];
|
||||
for (p, q) in ps.into_iter().zip(qs.into_iter()) {
|
||||
for (p, q) in ps.iter().zip(qs.iter()) {
|
||||
pairs.push((p, q.ell_coeffs.iter()));
|
||||
}
|
||||
let mut f = Self::GTGadget::one(cs.ns(|| "one"))?;
|
||||
|
||||
Reference in New Issue
Block a user