mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Profile import_assets better
This commit is contained in:
parent
821e8369d9
commit
4d4ac1d4fa
1 changed files with 5 additions and 0 deletions
|
@ -244,6 +244,7 @@ impl<'a> ImportAssets<'a> {
|
||||||
prefixed: Option<PrefixKind>,
|
prefixed: Option<PrefixKind>,
|
||||||
defs_for_candidate_name: impl Iterator<Item = Either<ModuleDef, MacroDef>>,
|
defs_for_candidate_name: impl Iterator<Item = Either<ModuleDef, MacroDef>>,
|
||||||
) -> FxHashSet<LocatedImport> {
|
) -> FxHashSet<LocatedImport> {
|
||||||
|
let _p = profile::span("import_assets::applicable_defs");
|
||||||
let current_crate = self.module_with_candidate.krate();
|
let current_crate = self.module_with_candidate.krate();
|
||||||
|
|
||||||
let mod_path = |item| get_mod_path(db, item, &self.module_with_candidate, prefixed);
|
let mod_path = |item| get_mod_path(db, item, &self.module_with_candidate, prefixed);
|
||||||
|
@ -278,6 +279,8 @@ fn path_applicable_imports(
|
||||||
mod_path: impl Fn(ItemInNs) -> Option<ModPath> + Copy,
|
mod_path: impl Fn(ItemInNs) -> Option<ModPath> + Copy,
|
||||||
defs_for_candidate_name: impl Iterator<Item = Either<ModuleDef, MacroDef>>,
|
defs_for_candidate_name: impl Iterator<Item = Either<ModuleDef, MacroDef>>,
|
||||||
) -> FxHashSet<LocatedImport> {
|
) -> FxHashSet<LocatedImport> {
|
||||||
|
let _p = profile::span("import_assets::path_applicable_imports");
|
||||||
|
|
||||||
let items_for_candidate_name =
|
let items_for_candidate_name =
|
||||||
defs_for_candidate_name.map(|def| def.either(ItemInNs::from, ItemInNs::from));
|
defs_for_candidate_name.map(|def| def.either(ItemInNs::from, ItemInNs::from));
|
||||||
|
|
||||||
|
@ -306,6 +309,7 @@ fn import_for_item(
|
||||||
unresolved_qualifier: &str,
|
unresolved_qualifier: &str,
|
||||||
original_item: ItemInNs,
|
original_item: ItemInNs,
|
||||||
) -> Option<LocatedImport> {
|
) -> Option<LocatedImport> {
|
||||||
|
let _p = profile::span("import_assets::import_for_item");
|
||||||
let (item_candidate, trait_to_import) = match original_item.as_module_def_id() {
|
let (item_candidate, trait_to_import) = match original_item.as_module_def_id() {
|
||||||
Some(module_def_id) => {
|
Some(module_def_id) => {
|
||||||
match ModuleDef::from(module_def_id).as_assoc_item(db).map(|assoc| assoc.container(db))
|
match ModuleDef::from(module_def_id).as_assoc_item(db).map(|assoc| assoc.container(db))
|
||||||
|
@ -397,6 +401,7 @@ fn trait_applicable_items(
|
||||||
mod_path: impl Fn(ItemInNs) -> Option<ModPath>,
|
mod_path: impl Fn(ItemInNs) -> Option<ModPath>,
|
||||||
defs_for_candidate_name: impl Iterator<Item = Either<ModuleDef, MacroDef>>,
|
defs_for_candidate_name: impl Iterator<Item = Either<ModuleDef, MacroDef>>,
|
||||||
) -> FxHashSet<LocatedImport> {
|
) -> FxHashSet<LocatedImport> {
|
||||||
|
let _p = profile::span("import_assets::trait_applicable_items");
|
||||||
let mut required_assoc_items = FxHashSet::default();
|
let mut required_assoc_items = FxHashSet::default();
|
||||||
|
|
||||||
let trait_candidates = defs_for_candidate_name
|
let trait_candidates = defs_for_candidate_name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue