From 3e447385479b63d7376d0ca6ffcb962a40b5ef5f Mon Sep 17 00:00:00 2001 From: James Zaki Date: Fri, 13 Dec 2024 12:44:31 +0000 Subject: [PATCH] docs: separate if/loop tip --- docs/docs/explainers/explainer-writing-noir.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/docs/docs/explainers/explainer-writing-noir.md b/docs/docs/explainers/explainer-writing-noir.md index dbdada2dc09..b927dba2d06 100644 --- a/docs/docs/explainers/explainer-writing-noir.md +++ b/docs/docs/explainers/explainer-writing-noir.md @@ -140,18 +140,6 @@ Use arrays and indices that are known at compile time where possible. Using `assert_constant(i);` before an index, `i`, is used in an array will give a compile error if `i` is NOT known at compile time. ::: -### Reduce what is inside loops and conditional logic - -Putting less logic inside an `if` (`else`, etc) paths, or inside a loop, translates to less gates required to represent the program. - -A loop duplicates the gates for each iteration of the loop, or put another way, "unwraps" or "flattens" the loop. Any calculations/calls that are unchanged in the loop should be calculated once before, and the result used in the loop. - -An `if` will create gates representing each path even though execution will use only one. Furthermore, there are additional operations required for each path. Sometimes this can have a multiplying effect on the operations in the `if` and `else` etc. - -:::tip -Only have essential computation inside conditional logic and loops, and calculate anything else once (before, or after, depending). -::: - ### Leverage unconstrained execution Constrained verification can leverage unconstrained execution, this is especially useful for operations that are represented by many gates.