From b825107bbc04244d2007fac6d6a3b903bd31093d Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 10 Aug 2023 14:00:56 +0100 Subject: [PATCH] chore: replace for-loop with `try_vecmap` --- crates/nargo_cli/src/cli/info_cmd.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/nargo_cli/src/cli/info_cmd.rs b/crates/nargo_cli/src/cli/info_cmd.rs index af3e3ccd4f3..2518c402605 100644 --- a/crates/nargo_cli/src/cli/info_cmd.rs +++ b/crates/nargo_cli/src/cli/info_cmd.rs @@ -1,5 +1,6 @@ use acvm::Backend; use clap::Args; +use iter_extended::try_vecmap; use nargo::{package::Package, prepare_package}; use nargo_toml::{find_package_manifest, resolve_workspace_from_toml}; use noirc_driver::{compile_contracts, CompileOptions}; @@ -77,14 +78,13 @@ fn count_opcodes_and_gates_in_contracts( let contracts = report_errors(result, &context, compile_options.deny_warnings)?; for contract in contracts { - let mut function_info = Vec::new(); - for function in contract.functions { + let function_info: Vec<(String, usize, u32)> = try_vecmap(contract.functions, |function| { let num_opcodes = function.bytecode.opcodes.len(); - let exact_circuit_size = backend - .get_exact_circuit_size(&function.bytecode) - .map_err(CliError::ProofSystemCompilerError)?; - function_info.push((function.name, num_opcodes, exact_circuit_size)); - } + let exact_circuit_size = backend.get_exact_circuit_size(&function.bytecode)?; + + Ok((function.name, num_opcodes, exact_circuit_size)) + }) + .map_err(CliError::ProofSystemCompilerError)?; for info in function_info { println!("[{}]({}) Total ACIR opcodes generated: {}", contract.name, info.0, info.1,);