Skip to content

Commit b3af191

Browse files
committed
Auto merge of #16107 - Veykril:rev-16101, r=Veykril
internal: Partially revert #16101 #16101 has severe perf regressions unfortunately, so this reverts the part that fixed the issues for now.
2 parents 5d7453c + 7cc6b0f commit b3af191

File tree

3 files changed

+47
-15
lines changed

3 files changed

+47
-15
lines changed

crates/hir-def/src/import_map.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -413,22 +413,17 @@ pub fn search_dependencies(
413413
while let Some((_, indexed_values)) = stream.next() {
414414
for &IndexedValue { index, value } in indexed_values {
415415
let import_map = &import_maps[index];
416-
let importables = &import_map.importables[value as usize..];
417-
418-
// Find the first item in this group that has a matching assoc mode and slice the rest away
419-
let Some(importable) =
420-
importables.iter().position(|it| query.matches_assoc_mode(import_map.map[it].1))
421-
else {
416+
let importables @ [importable, ..] = &import_map.importables[value as usize..] else {
422417
continue;
423418
};
424-
let importables @ [importable, ..] = &importables[importable..] else {
419+
let &(ref importable_data, is_trait_assoc_item) = &import_map.map[importable];
420+
if !query.matches_assoc_mode(is_trait_assoc_item) {
425421
continue;
426-
};
422+
}
427423

428424
// Fetch all the known names of this importable item (to handle import aliases/renames)
429425
common_importable_data_scratch.extend(
430-
import_map.map[importable]
431-
.0
426+
importable_data
432427
.iter()
433428
.filter(|&info| query.import_matches(info, true))
434429
// Name shared by the importable items in this group.

crates/ide-db/src/items_locator.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ pub fn items_with_name<'a>(
3737
| NameToImport::Exact(exact_name, case_sensitive) => {
3838
let mut local_query = symbol_index::Query::new(exact_name.clone());
3939
let mut external_query =
40-
import_map::Query::new(exact_name).assoc_search_mode(assoc_item_search);
40+
// import_map::Query::new(exact_name).assoc_search_mode(assoc_item_search);
41+
import_map::Query::new(exact_name);
4142
if prefix {
4243
local_query.prefix();
4344
external_query = external_query.prefix();

crates/rust-analyzer/src/integrated_benchmarks.rs

+40-4
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,46 @@ fn integrated_completion_benchmark() {
109109
vfs.file_id(&path).unwrap_or_else(|| panic!("can't find virtual file for {path}"))
110110
};
111111

112+
// kick off parsing and index population
113+
114+
let completion_offset = {
115+
let _it = stdx::timeit("change");
116+
let mut text = host.analysis().file_text(file_id).unwrap().to_string();
117+
let completion_offset =
118+
patch(&mut text, "db.struct_data(self.id)", "sel;\ndb.struct_data(self.id)")
119+
+ "sel".len();
120+
let mut change = Change::new();
121+
change.change_file(file_id, Some(Arc::from(text)));
122+
host.apply_change(change);
123+
completion_offset
124+
};
125+
112126
{
113-
let _it = stdx::timeit("initial");
127+
let _span = profile::cpu_span();
114128
let analysis = host.analysis();
115-
analysis.highlight_as_html(file_id, false).unwrap();
129+
let config = CompletionConfig {
130+
enable_postfix_completions: true,
131+
enable_imports_on_the_fly: true,
132+
enable_self_on_the_fly: true,
133+
enable_private_editable: true,
134+
full_function_signatures: false,
135+
callable: Some(CallableSnippets::FillArguments),
136+
snippet_cap: SnippetCap::new(true),
137+
insert_use: InsertUseConfig {
138+
granularity: ImportGranularity::Crate,
139+
prefix_kind: hir::PrefixKind::ByCrate,
140+
enforce_granularity: true,
141+
group: true,
142+
skip_glob_imports: true,
143+
},
144+
snippets: Vec::new(),
145+
prefer_no_std: false,
146+
prefer_prelude: true,
147+
limit: None,
148+
};
149+
let position =
150+
FilePosition { file_id, offset: TextSize::try_from(completion_offset).unwrap() };
151+
analysis.completions(&config, position, None).unwrap();
116152
}
117153

118154
profile::init_from("*>5");
@@ -122,8 +158,8 @@ fn integrated_completion_benchmark() {
122158
let _it = stdx::timeit("change");
123159
let mut text = host.analysis().file_text(file_id).unwrap().to_string();
124160
let completion_offset =
125-
patch(&mut text, "db.struct_data(self.id)", "sel;\ndb.struct_data(self.id)")
126-
+ "sel".len();
161+
patch(&mut text, "sel;\ndb.struct_data(self.id)", ";sel;\ndb.struct_data(self.id)")
162+
+ ";sel".len();
127163
let mut change = Change::new();
128164
change.change_file(file_id, Some(Arc::from(text)));
129165
host.apply_change(change);

0 commit comments

Comments
 (0)