Skip to content
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

Avoid creating deep recursive calls with Command::and #315

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

charypar
Copy link
Member

@charypar charypar commented Feb 3, 2025

Previous implementation of Command::and would create a cons-list shaped structure when folding over a list of commands with .and. This change makes it effectively equivalent to creating the folded list with ::all by wrapping the other command in .and to be hosted on selfs pair of channels, and spawning it in self.

As a side effect, this also adds a spawn API on a mutable command instance. Being pretty much equivalent with Command::new in what it can do, I think this can be public, but I could be talked out of that :).

There are potentially other similar optimisations in other places which wrap existing commands in new commands rather than merging them.

@charypar charypar requested a review from StuartHarris February 3, 2025 11:29
@charypar charypar force-pushed the viktor/fix-command-and branch from 0eaa6f8 to 1d6e514 Compare February 3, 2025 11:33
@charypar charypar merged commit 3889195 into master Feb 3, 2025
9 checks passed
@charypar charypar deleted the viktor/fix-command-and branch February 3, 2025 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants