Skip to content

Commit

Permalink
Avoid cloning transition
Browse files Browse the repository at this point in the history
clean up access of last element
  • Loading branch information
vicsn committed May 19, 2023
1 parent df58d23 commit a5fb2b7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions synthesizer/src/process/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl<N: Network> Process<N> {
lap!(timer, "Execute the circuit");

// Extract the execution.
let execution = Arc::try_unwrap(execution).unwrap().into_inner();
let mut execution = Arc::try_unwrap(execution).unwrap().into_inner();
// Ensure the execution contains 1 transition.
ensure!(execution.len() == 1, "Execution of '{}/{}' does not contain 1 transition", program_id, function_name);
// Extract the inclusion.
Expand All @@ -140,9 +140,11 @@ impl<N: Network> Process<N> {
let metrics = Arc::try_unwrap(metrics).unwrap().into_inner();
// Extract the assignments
let assignments = Arc::try_unwrap(assignments).unwrap_or_default().into_inner();
// Extract the transition
let transition = execution.pop()?;

finish!(timer);

Ok((response, execution.peek()?.clone(), inclusion, assignments, metrics))
Ok((response, transition, inclusion, assignments, metrics))
}
}
2 changes: 1 addition & 1 deletion synthesizer/src/process/stack/execution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<N: Network> Execution<N> {
ensure!(!assignments.is_empty(), "Number of assignments must be greater than zero!");

let inclusion_name = Identifier::<N>::from_str(N::INCLUSION_FUNCTION_NAME)?;
let proves_inclusion = *function_names[function_names.len() - 1] == inclusion_name;
let proves_inclusion = **function_names.last().unwrap() == inclusion_name;
let proof = batch.prove(function_names, assignments, proves_inclusion, rng)?;

self.proof = Some(proof);
Expand Down
2 changes: 1 addition & 1 deletion synthesizer/src/process/stack/fee/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl<N: Network> Fee<N> {
if assignments.len() == 2 && *function_names[1] != inclusion_name {
bail!("Expected 2nd assignment to belong to inclusion")
}
let proves_inclusion = *function_names[function_names.len() - 1] == inclusion_name;
let proves_inclusion = **function_names.last().unwrap() == inclusion_name;
let proof = batch.prove(function_names.as_slice(), assignments, proves_inclusion, rng)?;

self.proof = Some(proof);
Expand Down

0 comments on commit a5fb2b7

Please sign in to comment.