Auto merge of #16107 - Veykril:rev-16101, r=Veykril
internal: Partially revert #16101 https://github.com/rust-lang/rust-analyzer/pull/16101 has severe perf regressions unfortunately, so this reverts the part that fixed the issues for now.
This commit is contained in:
commit
b3af1916cc
@ -413,22 +413,17 @@ pub fn search_dependencies(
|
|||||||
while let Some((_, indexed_values)) = stream.next() {
|
while let Some((_, indexed_values)) = stream.next() {
|
||||||
for &IndexedValue { index, value } in indexed_values {
|
for &IndexedValue { index, value } in indexed_values {
|
||||||
let import_map = &import_maps[index];
|
let import_map = &import_maps[index];
|
||||||
let importables = &import_map.importables[value as usize..];
|
let importables @ [importable, ..] = &import_map.importables[value as usize..] else {
|
||||||
|
|
||||||
// Find the first item in this group that has a matching assoc mode and slice the rest away
|
|
||||||
let Some(importable) =
|
|
||||||
importables.iter().position(|it| query.matches_assoc_mode(import_map.map[it].1))
|
|
||||||
else {
|
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let importables @ [importable, ..] = &importables[importable..] else {
|
let &(ref importable_data, is_trait_assoc_item) = &import_map.map[importable];
|
||||||
|
if !query.matches_assoc_mode(is_trait_assoc_item) {
|
||||||
continue;
|
continue;
|
||||||
};
|
}
|
||||||
|
|
||||||
// Fetch all the known names of this importable item (to handle import aliases/renames)
|
// Fetch all the known names of this importable item (to handle import aliases/renames)
|
||||||
common_importable_data_scratch.extend(
|
common_importable_data_scratch.extend(
|
||||||
import_map.map[importable]
|
importable_data
|
||||||
.0
|
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|&info| query.import_matches(info, true))
|
.filter(|&info| query.import_matches(info, true))
|
||||||
// Name shared by the importable items in this group.
|
// Name shared by the importable items in this group.
|
||||||
|
@ -37,7 +37,8 @@ pub fn items_with_name<'a>(
|
|||||||
| NameToImport::Exact(exact_name, case_sensitive) => {
|
| NameToImport::Exact(exact_name, case_sensitive) => {
|
||||||
let mut local_query = symbol_index::Query::new(exact_name.clone());
|
let mut local_query = symbol_index::Query::new(exact_name.clone());
|
||||||
let mut external_query =
|
let mut external_query =
|
||||||
import_map::Query::new(exact_name).assoc_search_mode(assoc_item_search);
|
// import_map::Query::new(exact_name).assoc_search_mode(assoc_item_search);
|
||||||
|
import_map::Query::new(exact_name);
|
||||||
if prefix {
|
if prefix {
|
||||||
local_query.prefix();
|
local_query.prefix();
|
||||||
external_query = external_query.prefix();
|
external_query = external_query.prefix();
|
||||||
|
@ -109,10 +109,46 @@ fn integrated_completion_benchmark() {
|
|||||||
vfs.file_id(&path).unwrap_or_else(|| panic!("can't find virtual file for {path}"))
|
vfs.file_id(&path).unwrap_or_else(|| panic!("can't find virtual file for {path}"))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// kick off parsing and index population
|
||||||
|
|
||||||
|
let completion_offset = {
|
||||||
|
let _it = stdx::timeit("change");
|
||||||
|
let mut text = host.analysis().file_text(file_id).unwrap().to_string();
|
||||||
|
let completion_offset =
|
||||||
|
patch(&mut text, "db.struct_data(self.id)", "sel;\ndb.struct_data(self.id)")
|
||||||
|
+ "sel".len();
|
||||||
|
let mut change = Change::new();
|
||||||
|
change.change_file(file_id, Some(Arc::from(text)));
|
||||||
|
host.apply_change(change);
|
||||||
|
completion_offset
|
||||||
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
let _it = stdx::timeit("initial");
|
let _span = profile::cpu_span();
|
||||||
let analysis = host.analysis();
|
let analysis = host.analysis();
|
||||||
analysis.highlight_as_html(file_id, false).unwrap();
|
let config = CompletionConfig {
|
||||||
|
enable_postfix_completions: true,
|
||||||
|
enable_imports_on_the_fly: true,
|
||||||
|
enable_self_on_the_fly: true,
|
||||||
|
enable_private_editable: true,
|
||||||
|
full_function_signatures: false,
|
||||||
|
callable: Some(CallableSnippets::FillArguments),
|
||||||
|
snippet_cap: SnippetCap::new(true),
|
||||||
|
insert_use: InsertUseConfig {
|
||||||
|
granularity: ImportGranularity::Crate,
|
||||||
|
prefix_kind: hir::PrefixKind::ByCrate,
|
||||||
|
enforce_granularity: true,
|
||||||
|
group: true,
|
||||||
|
skip_glob_imports: true,
|
||||||
|
},
|
||||||
|
snippets: Vec::new(),
|
||||||
|
prefer_no_std: false,
|
||||||
|
prefer_prelude: true,
|
||||||
|
limit: None,
|
||||||
|
};
|
||||||
|
let position =
|
||||||
|
FilePosition { file_id, offset: TextSize::try_from(completion_offset).unwrap() };
|
||||||
|
analysis.completions(&config, position, None).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
profile::init_from("*>5");
|
profile::init_from("*>5");
|
||||||
@ -122,8 +158,8 @@ fn integrated_completion_benchmark() {
|
|||||||
let _it = stdx::timeit("change");
|
let _it = stdx::timeit("change");
|
||||||
let mut text = host.analysis().file_text(file_id).unwrap().to_string();
|
let mut text = host.analysis().file_text(file_id).unwrap().to_string();
|
||||||
let completion_offset =
|
let completion_offset =
|
||||||
patch(&mut text, "db.struct_data(self.id)", "sel;\ndb.struct_data(self.id)")
|
patch(&mut text, "sel;\ndb.struct_data(self.id)", ";sel;\ndb.struct_data(self.id)")
|
||||||
+ "sel".len();
|
+ ";sel".len();
|
||||||
let mut change = Change::new();
|
let mut change = Change::new();
|
||||||
change.change_file(file_id, Some(Arc::from(text)));
|
change.change_file(file_id, Some(Arc::from(text)));
|
||||||
host.apply_change(change);
|
host.apply_change(change);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user