-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
refactor(libutil/topo-sort): return variant instead of throwing #14479
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
refactor(libutil/topo-sort): return variant instead of throwing #14479
Conversation
roberth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good incremental improvement
| auto orifu = get(outputReferencesIfUnregistered, name); | ||
| if (!orifu) | ||
| auto topoSortResult = topoSort(outputsToSort, {[&](const std::string & name) { | ||
| auto orifu = get(outputReferencesIfUnregistered, name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking: too complicated name. Refactor might improve that by moving to a smaller scope, but no concrete suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(existing name it looks like)
| [&](const AlreadyRegistered &) { return StringSet{}; }, | ||
| [&](const PerhapsNeedToRegister & refs) { | ||
| StringSet referencedOutputs; | ||
| /* FIXME build inverted map up front so no quadratic waste here */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIXME
Pre-existing 🫠
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next PR has a fix for that :)
Ericson2314
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny nits, then tiny unit test, then looks good!
14c70d0 to
273f7a0
Compare
The variant has on the left-hand side the topologically sorted vector and the right-hand side is a pair showing the path and its parent that represent a cycle in the graph making the sort impossible. This change prepares for enhanced cycle error messages that can provide more context about the cycle. The variant approach allows callers to handle cycles more flexibly, enabling better error reporting that shows the full cycle path and which files are involved. Adapted from Lix commit f7871fcb5. Change-Id: I70a987f470437df8beb3b1cc203ff88701d0aa1b Co-Authored-By: Maximilian Bosch <maximilian@mbosch.me>
273f7a0 to
182ae39
Compare
Motivation
The variant has on the left-hand side the topologically sorted vector
and the right-hand side is a pair showing the path and its parent that
represent a cycle in the graph making the sort impossible.
This change prepares for enhanced cycle error messages that can provide
more context about the cycle. The variant approach allows callers to
handle cycles more flexibly, enabling better error reporting that shows
the full cycle path and which files are involved.
Adapted from Lix commit f7871fcb5.
Change-Id: I70a987f470437df8beb3b1cc203ff88701d0aa1b
Context
Taking another shot at #14218 with inspiration from how the Lix folks handled it :)
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.