diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-16 16:42:58 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-16 16:42:58 +0000 |
commit | adcc89137d3feea8f19fad461bbde6f4bce048e5 (patch) | |
tree | 160af959553ce57fdfcbc0a6c79bafcc3611aeea /crates/ra_hir_def/src/body | |
parent | 648df02953a6ebf87a5876668eceba208687e8a7 (diff) | |
parent | 9faea2364dee4fbc9391ad233c570b70256ef002 (diff) |
Merge #3584
3584: Switch to dynamic dispatch r=matklad a=matklad
Benches are in https://github.com/rust-analyzer/rust-analyzer/issues/1987#issuecomment-598807185
TL;DR:
* 33% faster release build
* slightly worse/same perf
* no changes for debug build
* slightly smaller binary
cc @flodiebold I genuinely don't know if it is a good idea or not.
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/body')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 11 | ||||
-rw-r--r-- | crates/ra_hir_def/src/body/scope.rs | 2 |
2 files changed, 5 insertions, 8 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 54b5591d3..6238de606 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -36,7 +36,7 @@ use crate::{ | |||
36 | }; | 36 | }; |
37 | 37 | ||
38 | pub(super) fn lower( | 38 | pub(super) fn lower( |
39 | db: &impl DefDatabase, | 39 | db: &dyn DefDatabase, |
40 | def: DefWithBodyId, | 40 | def: DefWithBodyId, |
41 | expander: Expander, | 41 | expander: Expander, |
42 | params: Option<ast::ParamList>, | 42 | params: Option<ast::ParamList>, |
@@ -58,8 +58,8 @@ pub(super) fn lower( | |||
58 | .collect(params, body) | 58 | .collect(params, body) |
59 | } | 59 | } |
60 | 60 | ||
61 | struct ExprCollector<DB> { | 61 | struct ExprCollector<'a> { |
62 | db: DB, | 62 | db: &'a dyn DefDatabase, |
63 | def: DefWithBodyId, | 63 | def: DefWithBodyId, |
64 | expander: Expander, | 64 | expander: Expander, |
65 | 65 | ||
@@ -67,10 +67,7 @@ struct ExprCollector<DB> { | |||
67 | source_map: BodySourceMap, | 67 | source_map: BodySourceMap, |
68 | } | 68 | } |
69 | 69 | ||
70 | impl<'a, DB> ExprCollector<&'a DB> | 70 | impl ExprCollector<'_> { |
71 | where | ||
72 | DB: DefDatabase, | ||
73 | { | ||
74 | fn collect( | 71 | fn collect( |
75 | mut self, | 72 | mut self, |
76 | param_list: Option<ast::ParamList>, | 73 | param_list: Option<ast::ParamList>, |
diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index a58a7b21f..7c3db8869 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs | |||
@@ -45,7 +45,7 @@ pub struct ScopeData { | |||
45 | } | 45 | } |
46 | 46 | ||
47 | impl ExprScopes { | 47 | impl ExprScopes { |
48 | pub(crate) fn expr_scopes_query(db: &impl DefDatabase, def: DefWithBodyId) -> Arc<ExprScopes> { | 48 | pub(crate) fn expr_scopes_query(db: &dyn DefDatabase, def: DefWithBodyId) -> Arc<ExprScopes> { |
49 | let body = db.body(def); | 49 | let body = db.body(def); |
50 | Arc::new(ExprScopes::new(&*body)) | 50 | Arc::new(ExprScopes::new(&*body)) |
51 | } | 51 | } |