-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove recursion in semantic::Policy::normalized
#614
base: master
Are you sure you want to change the base?
Remove recursion in semantic::Policy::normalized
#614
Commits on Oct 17, 2023
-
Remove unnecessary code comment, the local variables names are clear enough.
Configuration menu - View commit details
-
Copy full SHA for 67c0a1a - Browse repository at this point
Copy the full SHA 67c0a1aView commit details -
This function is fiendishly hard to understand, add a line of whitespace as a tiny baby step towards making it clearer.
Configuration menu - View commit details
-
Copy full SHA for 3401747 - Browse repository at this point
Copy the full SHA 3401747View commit details -
Currently we are using `map_or` in a convoluted manner, we can just use `unwrap_or` to get the inner value or default to 0. Refactor only, no logic changes.
Configuration menu - View commit details
-
Copy full SHA for f764508 - Browse repository at this point
Copy the full SHA f764508View commit details -
Improve spacing in error string
We have a little typo in an error string, fix it up.
Configuration menu - View commit details
-
Copy full SHA for 4043ce5 - Browse repository at this point
Copy the full SHA 4043ce5View commit details -
Use standard from for import statements. (Note `Arc` is already in scope in `super`.)
Configuration menu - View commit details
-
Copy full SHA for 7b561da - Browse repository at this point
Copy the full SHA 7b561daView commit details -
Move TreeLike impl to concrete module
When we implemented the `TreeLike` trait for the concrete `Policy` we put it in the `iter` module, it doesn't really live there, better to put the impl in the same place as the definition of the implementor. Move the impl of `TreeLike` for `concrete::Policy` to the `concrete` module.
Configuration menu - View commit details
-
Copy full SHA for 3592e9b - Browse repository at this point
Copy the full SHA 3592e9bView commit details -
Add Arc to the semantic::Policy::Thresh vector
In preparation for removing recursive algorithms in the `semantic` module add an `Arc` wrapper around the policies in the `Thresh` vector. Note we use the more explicit `Arc::new` instead of `into` because a lot of these should be removed when we remove recursion, later it may be necessary to check that we are not creating new references when a clone will suffice, the explicit `Arc::new` is easier to check. In tests however just use `into`.
Configuration menu - View commit details
-
Copy full SHA for 2017942 - Browse repository at this point
Copy the full SHA 2017942View commit details -
Implement TreeLike for semantic::Policy
In preparation for removing recursive algorithms in the `semantic` module implement the `TreeLike` trait to enable iteration over policy nodes. This is a direct copy of the `concrete::Policy` impl with the `And` and `Or` variants removed.
Configuration menu - View commit details
-
Copy full SHA for 8bfb717 - Browse repository at this point
Copy the full SHA 8bfb717View commit details -
semantic: Remove recursion in for_each_key
Done as part of the effort to remove all the recursion crate wide. Use the `TreeLike` trait to iterate over policy nodes and remove the recursive call in `semantic::Policy::for_each_key`.
Configuration menu - View commit details
-
Copy full SHA for 10011db - Browse repository at this point
Copy the full SHA 10011dbView commit details -
semantic: Remove recursion in translate_pk
Done as part of the effort to remove all the recursion crate wide. Use the `TreeLike` trait to iterate over policy nodes and remove the recursive call in `semantic::Policy::translate_pk`.
Configuration menu - View commit details
-
Copy full SHA for 10a77fa - Browse repository at this point
Copy the full SHA 10a77faView commit details -
semantic: Remove recursion in n_terminals
Done as part of the effort to remove all the recursion crate wide. Use the `TreeLike` trait to iterate over policy nodes and remove the recursive call in `semantic::Policy::n_terminals`.
Configuration menu - View commit details
-
Copy full SHA for 48a0af8 - Browse repository at this point
Copy the full SHA 48a0af8View commit details -
semantic: Remove recursion in real_*_timelocks
Done as part of the effort to remove all the recursion crate wide. Use the `TreeLike` trait to iterate over policy nodes and remove the recursive call in the `semantic::Policy::real_*_timelocks` functions. Done together because they are basically identical.
Configuration menu - View commit details
-
Copy full SHA for 2c422e6 - Browse repository at this point
Copy the full SHA 2c422e6View commit details -
semantic: Remove recursion in at_age and at_lock_time
Done as part of the effort to remove all the recursion crate wide. Use the `TreeLike` trait to iterate over policy nodes and remove the recursive call in `semantic::Policy::at_age` and `semantic::Policy::at_age`. Done together because they are basically identical.
Configuration menu - View commit details
-
Copy full SHA for 1d536cb - Browse repository at this point
Copy the full SHA 1d536cbView commit details -
semantic: Remove recursion in n_keys
Done as part of the effort to remove all the recursion crate wide. Use the `TreeLike` trait to iterate over policy nodes and remove the recursive call in `semantic::Policy::n_keys`.
Configuration menu - View commit details
-
Copy full SHA for ef98b6b - Browse repository at this point
Copy the full SHA ef98b6bView commit details -
semantic: Remove recursion in minimum_n_keys
Done as part of the effort to remove all the recursion crate wide. Use the `TreeLike` trait to iterate over policy nodes and remove the recursive call in `semantic::Policy::minimum_n_keys`.
Configuration menu - View commit details
-
Copy full SHA for e890d8f - Browse repository at this point
Copy the full SHA e890d8fView commit details -
semantic: Remove recursion in sorted
Done as part of the effort to remove all the recursion crate wide. Use the `TreeLike` trait to iterate over policy nodes and remove the recursive call in `semantic::Policy::sorted`.
Configuration menu - View commit details
-
Copy full SHA for 0421aef - Browse repository at this point
Copy the full SHA 0421aefView commit details -
The `semantic::Policy::normalized` function is recursive and has nested processing of `Threshold`s. It is not trivial to fully grok. The function is already tested elsewhere in the unit tests but we don't have simple single purpose tests for it. Add various unit tests for `normalized`, these serve as documentation of the function as much as anything.
Configuration menu - View commit details
-
Copy full SHA for 285214e - Browse repository at this point
Copy the full SHA 285214eView commit details -
Clone sub instead of creating new Arc
Currently we are creating a new `Arc<Policy::Threshold>` from the pieces of `sub` that we pattern matched on. We can just clone the original `sub` instead.
Configuration menu - View commit details
-
Copy full SHA for d3d4564 - Browse repository at this point
Copy the full SHA d3d4564View commit details -
Refactor to use parent/child notation
In `normalized` we process the threshold policy as well as its child threshold policy and we shadow `subs` - this is all very confusing. Add parent/child terminology and a couple extra local variables in an attempt to make the code more clear. Refactor only, no logic changes.
Configuration menu - View commit details
-
Copy full SHA for 2c3d41d - Browse repository at this point
Copy the full SHA 2c3d41dView commit details -
Pull the (m, n) calculation out into sub function
The `normalize` function spans more than a screen (on my monitor), as such it is hard to work on. Refactor out the (m, n)-thresh calculation to a function so that the body of the function becomes shorter. Refactor only, no logic changes.
Configuration menu - View commit details
-
Copy full SHA for 6449f38 - Browse repository at this point
Copy the full SHA 6449f38View commit details -
Remove recursion in normalized
Remove the recursive call in `semantic::Policy::normalized`, using the `TreeLike` trait to iterate nodes instead.
Configuration menu - View commit details
-
Copy full SHA for 1f0486b - Browse repository at this point
Copy the full SHA 1f0486bView commit details