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
@@ -32,7 +32,7 @@ impl<ConstraintF: PrimeField> CommitmentGadget<Blake2sCommitment, ConstraintF>
|
||||
r: &Self::RandomnessGadget,
|
||||
) -> Result<Self::OutputGadget, SynthesisError> {
|
||||
let mut input_bits = Vec::with_capacity(512);
|
||||
for byte in input.into_iter().chain(r.0.iter()) {
|
||||
for byte in input.iter().chain(r.0.iter()) {
|
||||
input_bits.extend_from_slice(&byte.into_bits_le());
|
||||
}
|
||||
let mut result = Vec::new();
|
||||
@@ -141,13 +141,13 @@ mod test {
|
||||
let primitive_result = Blake2sCommitment::commit(¶meters, &input, &randomness).unwrap();
|
||||
|
||||
let mut input_bytes = vec![];
|
||||
for (byte_i, input_byte) in input.into_iter().enumerate() {
|
||||
for (byte_i, input_byte) in input.iter().enumerate() {
|
||||
let cs = cs.ns(|| format!("input_byte_gadget_{}", byte_i));
|
||||
input_bytes.push(UInt8::alloc(cs, || Ok(*input_byte)).unwrap());
|
||||
}
|
||||
|
||||
let mut randomness_bytes = vec![];
|
||||
for (byte_i, random_byte) in randomness.into_iter().enumerate() {
|
||||
for (byte_i, random_byte) in randomness.iter().enumerate() {
|
||||
let cs = cs.ns(|| format!("randomness_byte_gadget_{}", byte_i));
|
||||
randomness_bytes.push(UInt8::alloc(cs, || Ok(*random_byte)).unwrap());
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ mod test {
|
||||
PedersenCommitment::<JubJub, Window>::commit(¶meters, &input, &randomness).unwrap();
|
||||
|
||||
let mut input_bytes = vec![];
|
||||
for (byte_i, input_byte) in input.into_iter().enumerate() {
|
||||
for (byte_i, input_byte) in input.iter().enumerate() {
|
||||
let cs = cs.ns(|| format!("input_byte_gadget_{}", byte_i));
|
||||
input_bytes.push(UInt8::alloc(cs, || Ok(*input_byte)).unwrap());
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ where
|
||||
// Allocate new variable for the result.
|
||||
let input_in_bits = input_in_bits
|
||||
.chunks(W::WINDOW_SIZE * CHUNK_SIZE)
|
||||
.map(|x| x.chunks(CHUNK_SIZE).into_iter().collect::<Vec<_>>())
|
||||
.map(|x| x.chunks(CHUNK_SIZE).collect::<Vec<_>>())
|
||||
.collect::<Vec<_>>();
|
||||
let result = GG::precomputed_base_3_bit_signed_digit_scalar_mul(
|
||||
cs,
|
||||
@@ -159,7 +159,7 @@ mod test {
|
||||
rng.fill_bytes(&mut input);
|
||||
|
||||
let mut input_bytes = vec![];
|
||||
for (byte_i, input_byte) in input.into_iter().enumerate() {
|
||||
for (byte_i, input_byte) in input.iter().enumerate() {
|
||||
let cs = cs.ns(|| format!("input_byte_gadget_{}", byte_i));
|
||||
input_bytes.push(UInt8::alloc(cs, || Ok(*input_byte)).unwrap());
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ mod test {
|
||||
rng.fill_bytes(&mut input);
|
||||
|
||||
let mut input_bytes = vec![];
|
||||
for (byte_i, input_byte) in input.into_iter().enumerate() {
|
||||
for (byte_i, input_byte) in input.iter().enumerate() {
|
||||
let cs = cs.ns(|| format!("input_byte_gadget_{}", byte_i));
|
||||
input_bytes.push(UInt8::alloc(cs, || Ok(*input_byte)).unwrap());
|
||||
}
|
||||
|
||||
@@ -482,7 +482,7 @@ impl<ConstraintF: PrimeField> PRFGadget<Blake2s, ConstraintF> for Blake2sGadget
|
||||
assert_eq!(seed.len(), 32);
|
||||
// assert_eq!(input.len(), 32);
|
||||
let mut gadget_input = Vec::with_capacity(512);
|
||||
for byte in seed.into_iter().chain(input) {
|
||||
for byte in seed.iter().chain(input) {
|
||||
gadget_input.extend_from_slice(&byte.into_bits_le());
|
||||
}
|
||||
let mut result = Vec::new();
|
||||
|
||||
Reference in New Issue
Block a user