aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db/src
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2021-03-01 12:27:07 +0000
committerKirill Bulatov <[email protected]>2021-03-08 21:59:20 +0000
commit4d4ac1d4fa0aba107a27d3fd2d209304dfe69b9f (patch)
treeb361024860a0d6d85d93ec77e6b04b89fb6871dd /crates/ide_db/src
parent821e8369d994ebca39ccbf9b449c604d0c910efc (diff)
Profile import_assets better
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r--crates/ide_db/src/helpers/import_assets.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/crates/ide_db/src/helpers/import_assets.rs b/crates/ide_db/src/helpers/import_assets.rs
index 4e352d546..a30a4dd9d 100644
--- a/crates/ide_db/src/helpers/import_assets.rs
+++ b/crates/ide_db/src/helpers/import_assets.rs
@@ -244,6 +244,7 @@ impl<'a> ImportAssets<'a> {
244 prefixed: Option<PrefixKind>, 244 prefixed: Option<PrefixKind>,
245 defs_for_candidate_name: impl Iterator<Item = Either<ModuleDef, MacroDef>>, 245 defs_for_candidate_name: impl Iterator<Item = Either<ModuleDef, MacroDef>>,
246 ) -> FxHashSet<LocatedImport> { 246 ) -> FxHashSet<LocatedImport> {
247 let _p = profile::span("import_assets::applicable_defs");
247 let current_crate = self.module_with_candidate.krate(); 248 let current_crate = self.module_with_candidate.krate();
248 249
249 let mod_path = |item| get_mod_path(db, item, &self.module_with_candidate, prefixed); 250 let mod_path = |item| get_mod_path(db, item, &self.module_with_candidate, prefixed);
@@ -278,6 +279,8 @@ fn path_applicable_imports(
278 mod_path: impl Fn(ItemInNs) -> Option<ModPath> + Copy, 279 mod_path: impl Fn(ItemInNs) -> Option<ModPath> + Copy,
279 defs_for_candidate_name: impl Iterator<Item = Either<ModuleDef, MacroDef>>, 280 defs_for_candidate_name: impl Iterator<Item = Either<ModuleDef, MacroDef>>,
280) -> FxHashSet<LocatedImport> { 281) -> FxHashSet<LocatedImport> {
282 let _p = profile::span("import_assets::path_applicable_imports");
283
281 let items_for_candidate_name = 284 let items_for_candidate_name =
282 defs_for_candidate_name.map(|def| def.either(ItemInNs::from, ItemInNs::from)); 285 defs_for_candidate_name.map(|def| def.either(ItemInNs::from, ItemInNs::from));
283 286
@@ -306,6 +309,7 @@ fn import_for_item(
306 unresolved_qualifier: &str, 309 unresolved_qualifier: &str,
307 original_item: ItemInNs, 310 original_item: ItemInNs,
308) -> Option<LocatedImport> { 311) -> Option<LocatedImport> {
312 let _p = profile::span("import_assets::import_for_item");
309 let (item_candidate, trait_to_import) = match original_item.as_module_def_id() { 313 let (item_candidate, trait_to_import) = match original_item.as_module_def_id() {
310 Some(module_def_id) => { 314 Some(module_def_id) => {
311 match ModuleDef::from(module_def_id).as_assoc_item(db).map(|assoc| assoc.container(db)) 315 match ModuleDef::from(module_def_id).as_assoc_item(db).map(|assoc| assoc.container(db))
@@ -397,6 +401,7 @@ fn trait_applicable_items(
397 mod_path: impl Fn(ItemInNs) -> Option<ModPath>, 401 mod_path: impl Fn(ItemInNs) -> Option<ModPath>,
398 defs_for_candidate_name: impl Iterator<Item = Either<ModuleDef, MacroDef>>, 402 defs_for_candidate_name: impl Iterator<Item = Either<ModuleDef, MacroDef>>,
399) -> FxHashSet<LocatedImport> { 403) -> FxHashSet<LocatedImport> {
404 let _p = profile::span("import_assets::trait_applicable_items");
400 let mut required_assoc_items = FxHashSet::default(); 405 let mut required_assoc_items = FxHashSet::default();
401 406
402 let trait_candidates = defs_for_candidate_name 407 let trait_candidates = defs_for_candidate_name