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

Optimize combinators for resolved cases #33

Merged
merged 1 commit into from
Oct 27, 2015
Merged

Conversation

grddev
Copy link
Collaborator

@grddev grddev commented Oct 21, 2015

This implements three optimizations, for three different combinators.

For Future::all, if a future is already known to be failed, we know upfront that the result will be a failed future, and we can reuse this result.

For Future::after, if a future is already resolved, there is no reason to keep it in the waiting list.

For Future::first, if a future is already known to be resolved, we know upfront that the result will be a resolved future, and we can reuse this result.

The implementations rely on resolved? and failed?, which according to the specs are not guaranteed to exist on a future, and thus the code has to check their presence before doing anything about it.

This implements three optimizations, for three different combinators.

For Future::all, if a future is already known to be failed, we know
upfront that the result will be a failed future, and we can reuse this
result.

For Future::after, if a future is already resolved, there is no reason
to keep it in the waiting list.

For Future::first, if a future is already known to be resolved, we know
upfront that the result will be a resolved future, and we can reuse this
result.

The implementations rely on `resolved?` and `failed?`, which according
to the specs are not guaranteed to exist on a future, and thus the code
has to check their presence before doing anything about it.
@iconara
Copy link
Owner

iconara commented Oct 27, 2015

Remind me to release a new version with this.

@iconara iconara merged commit 8f82379 into master Oct 27, 2015
@iconara iconara deleted the optimize-resolved-combine branch October 30, 2015 13:29
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