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

Move variable into the only branch where it is relevant #80643

Merged
merged 1 commit into from
Jan 5, 2021

Conversation

LingMan
Copy link
Contributor

@LingMan LingMan commented Jan 3, 2021

At the if branch filter (the let binding) is None iff filter (the parameter) was None.
We can branch on the parameter, move the binding into the if, and the complexity of handling
Option<Option<_> largely dissolves.

@rustbot modify labels +C-cleanup +T-compiler

Note: I have no idea how hot this code is. If this method frequently gets called with a None filter, there might be a small perf improvement.

@rustbot rustbot added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 3, 2021
@rust-highfive
Copy link
Collaborator

r? @davidtwco

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 3, 2021
At the `if` branch `filter` (the `let` binding) is `None` iff `filter` (the parameter) was `None`.
We can branch on the parameter, move the binding into the `if`, and the complexity of handling
`Option<Option<_>` largely dissolves.
@oli-obk
Copy link
Contributor

oli-obk commented Jan 4, 2021

you're really on a roll with these cleanups! Thanks for doing this

r? @oli-obk

@bors r+ rollup (I do not believe this will affect perf, I think hope llvm optimizations would figure this out)

@bors
Copy link
Contributor

bors commented Jan 4, 2021

📌 Commit af7134e has been approved by oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned davidtwco Jan 4, 2021
@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 4, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 5, 2021
Rollup of 12 pull requests

Successful merges:

 - rust-lang#80442 (Mention Arc::make_mut and Rc::make_mut in the documentation of Cow)
 - rust-lang#80533 (bootstrap: clippy fixes)
 - rust-lang#80538 (Add check for `[T;N]`/`usize` mismatch in astconv)
 - rust-lang#80612 (Remove reverted change from relnotes)
 - rust-lang#80627 (Builder: Warn if test file does not exist)
 - rust-lang#80637 (Use Option::filter instead of open-coding it)
 - rust-lang#80643 (Move variable into the only branch where it is relevant)
 - rust-lang#80656 (Fixed documentation error for `std::hint::spin_loop`)
 - rust-lang#80666 (Fix missing link for "fully qualified syntax")
 - rust-lang#80672 (./x.py clippy: allow the most noisy lints)
 - rust-lang#80677 (doc -- list edit for consistency)
 - rust-lang#80696 (make sure that promoteds which fail to evaluate in dead const code behave correctly)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 598d189 into rust-lang:master Jan 5, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 5, 2021
@LingMan LingMan deleted the unwrap branch January 5, 2021 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants