-
Notifications
You must be signed in to change notification settings - Fork 793
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
Simple mapping optimization fixes #17711
Merged
vzarytovskii
merged 10 commits into
dotnet:main
from
brianrourkeboll:dont-bind-wildcard
Sep 13, 2024
Merged
Simple mapping optimization fixes #17711
vzarytovskii
merged 10 commits into
dotnet:main
from
brianrourkeboll:dont-bind-wildcard
Sep 13, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
❗ Release notes required
|
* Evaluate `xs` exactly once in `[|for … in xs -> …|]` when `xs` is an array. * Don't rebind the loop variable or read from the source array when the loop variable is unused in the loop body in, e.g., `[|for _ in xs -> …|]` when `xs` is an array. * Handle more complex patterns for `pat` in `[|for pat in … -> …|]`, `[for pat in … -> …]`.
…ll/fsharp into dont-bind-wildcard
brianrourkeboll
changed the title
Don't rebind
Simple mapping optimization fixes
Sep 12, 2024
_
in [|for _ in … -> …|]
Thanks for the quick fix! |
This was referenced Sep 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Followup to #16832, #16948, #17067, etc.
Fixes #17708.
expr
exactly once in[|for … in expr -> …|]
whenexpr
is an array.[|for _ in expr -> …|]
whenexpr
is an array. There is no need to emit aldelem
fromexpr
and rebind it to the loop variable in this case since the loop variable is never used.pat
in[|for pat in … -> …|]
,[for pat in … -> …]
.Checklist
Notes
The diff for LowerComputedCollections.fs will be smaller if you view the diff with whitespace changes hidden.
Things to look for in the baseline diffs:
[|for … in expr -> …|]
whenexpr
is an array should be present/evaluated exactly once (and bound to a local usingstloc
).pat
is not used in the loop body in[|for pat in expr -> …|]
(e.g., whenpat
is_
) andexpr
is an array, there should be noldelem
that reads from the source array.pat
in[|for pat in … -> …|]
,[for pat in … -> …]
is something more complex than a named pattern or a wildcard.