From c4cb9df6a4f8ad2df6b5b5f3c0dac1d830da601c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Garillot?= Date: Thu, 6 Jul 2023 11:42:15 -0400 Subject: [PATCH] refactor: Refactor code for readability using Option::then - Optimized the slicing of the symbol path array in `store.rs` using shorthand syntax. - Utilized the `.then()` combinator --- src/eval/mod.rs | 6 +----- src/lem/store.rs | 2 +- src/proof/groth16.rs | 8 ++------ 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/eval/mod.rs b/src/eval/mod.rs index 2950243287..e3845e2524 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -218,11 +218,7 @@ impl IO { _ => 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) -> Result, store::Error> { diff --git a/src/lem/store.rs b/src/lem/store.rs index bb1910b47f..5ce64a7740 100644 --- a/src/lem/store.rs +++ b/src/lem/store.rs @@ -177,7 +177,7 @@ impl Store { 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); diff --git a/src/proof/groth16.rs b/src/proof/groth16.rs index 38b179cdc8..b2449d3c7f 100644 --- a/src/proof/groth16.rs +++ b/src/proof/groth16.rs @@ -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, @@ -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);