diff options
| author | bors <bors@rust-lang.org> | 2020-10-29 18:34:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-10-29 18:34:59 +0000 |
| commit | 6bdae9edd0cc099daa6038bca469dc09b6fc078a (patch) | |
| tree | 41d83b5e825e0679aabae87ced53403e2070254b /compiler/rustc_resolve/src | |
| parent | a53fb30e3bf2655b0563da6d561c23cda5f3ec11 (diff) | |
| parent | 1c1c591c81a6fba8199355066a4b4ca00df659b2 (diff) | |
| download | rust-6bdae9edd0cc099daa6038bca469dc09b6fc078a.tar.gz rust-6bdae9edd0cc099daa6038bca469dc09b6fc078a.zip | |
Auto merge of #78508 - wesleywiser:optimize_visit_scopes, r=petrochenkov
[resolve] Use `unwrap_or_else` instead of `unwrap_or` in a hot path This improves the performance of the `resolve_crate` function by 30% for a very large single file crate with auto-generated C bindings. cc `@rylev`
Diffstat (limited to 'compiler/rustc_resolve/src')
| -rw-r--r-- | compiler/rustc_resolve/src/lib.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index b12e516fa3e..902ee5f4d09 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1725,10 +1725,9 @@ impl<'a> Resolver<'a> { Scope::MacroRules(binding.parent_macro_rules_scope) } MacroRulesScope::Invocation(invoc_id) => Scope::MacroRules( - self.output_macro_rules_scopes - .get(&invoc_id) - .cloned() - .unwrap_or(self.invocation_parent_scopes[&invoc_id].macro_rules), + self.output_macro_rules_scopes.get(&invoc_id).cloned().unwrap_or_else( + || self.invocation_parent_scopes[&invoc_id].macro_rules, + ), ), MacroRulesScope::Empty => Scope::Module(module), }, |
