Skip to content

Commit

Permalink
refactor: Refactor code for readability using Option::then
Browse files Browse the repository at this point in the history
- Optimized the slicing of the symbol path array in `store.rs` using shorthand syntax.
- Utilized the `.then()` combinator
  • Loading branch information
huitseeker committed Jul 6, 2023
1 parent e5931d7 commit c4cb9df
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
6 changes: 1 addition & 5 deletions src/eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,7 @@ impl<F: LurkField> IO<F> {
_ => return None,
};

if expr.continuation.tag == crate::tag::ContTag::Emit {
Some(expr.value)
} else {
None
}
(expr.continuation.tag == crate::tag::ContTag::Emit).then_some(expr.value)
}

pub fn to_vector(&self, store: &Store<F>) -> Result<Vec<F>, store::Error> {
Expand Down
2 changes: 1 addition & 1 deletion src/lem/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl<F: LurkField> Store<F> {
match self.sym_cache.get(path) {
Some(ptr_cache) => *ptr_cache,
None => {
let tail = &path[1..path.len()];
let tail = &path[1..];
let tail_ptr = self.intern_symbol_path(tail);
let head = &path[0];
let head_ptr = self.intern_string(head);
Expand Down
8 changes: 2 additions & 6 deletions src/proof/groth16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,7 @@ mod tests {
check_cs_deltas(&cs, limit, lang_rc.clone());
}

let proof_results = if check_groth16 {
Some(
let proof_results = (check_groth16).then(||
groth_prover
.outer_prove(
groth_params,
Expand All @@ -445,10 +444,7 @@ mod tests {
lang_rc,
)
.unwrap(),
)
} else {
None
};
);

if let Some((proof, public_inputs, public_outputs)) = proof_results {
let srs_vk = INNER_PRODUCT_SRS.specialize_vk(proof.proof_count);
Expand Down

0 comments on commit c4cb9df

Please sign in to comment.