mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Do not process indexed values more than once
This commit is contained in:
parent
8f17f3d594
commit
128a6a4ec0
1 changed files with 31 additions and 29 deletions
|
@ -403,40 +403,42 @@ pub fn search_dependencies<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut stream = op.union();
|
let mut stream = op.union();
|
||||||
let mut res = FxHashSet::default();
|
|
||||||
|
let mut all_indexed_values = FxHashSet::default();
|
||||||
while let Some((_, indexed_values)) = stream.next() {
|
while let Some((_, indexed_values)) = stream.next() {
|
||||||
for indexed_value in indexed_values {
|
all_indexed_values.extend(indexed_values.iter().copied());
|
||||||
let import_map = &import_maps[indexed_value.index];
|
}
|
||||||
let importables = &import_map.importables[indexed_value.value as usize..];
|
|
||||||
|
|
||||||
let common_importable_data = &import_map.map[&importables[0]];
|
let mut res = FxHashSet::default();
|
||||||
if !query.import_matches(common_importable_data, true) {
|
for indexed_value in all_indexed_values {
|
||||||
continue;
|
let import_map = &import_maps[indexed_value.index];
|
||||||
}
|
let importables = &import_map.importables[indexed_value.value as usize..];
|
||||||
|
|
||||||
// Path shared by the importable items in this group.
|
let common_importable_data = &import_map.map[&importables[0]];
|
||||||
let common_importables_path_fst = fst_path(&common_importable_data.path);
|
if !query.import_matches(common_importable_data, true) {
|
||||||
// Add the items from this `ModPath` group. Those are all subsequent items in
|
continue;
|
||||||
// `importables` whose paths match `path`.
|
}
|
||||||
let iter = importables
|
|
||||||
.iter()
|
// Path shared by the importable items in this group.
|
||||||
.copied()
|
let common_importables_path_fst = fst_path(&common_importable_data.path);
|
||||||
.take_while(|item| {
|
// Add the items from this `ModPath` group. Those are all subsequent items in
|
||||||
common_importables_path_fst == fst_path(&import_map.map[item].path)
|
// `importables` whose paths match `path`.
|
||||||
})
|
let iter = importables
|
||||||
.filter(|&item| match item_import_kind(item) {
|
.iter()
|
||||||
Some(import_kind) => !query.exclude_import_kinds.contains(&import_kind),
|
.copied()
|
||||||
None => true,
|
.take_while(|item| common_importables_path_fst == fst_path(&import_map.map[item].path))
|
||||||
})
|
.filter(|&item| match item_import_kind(item) {
|
||||||
.filter(|item| {
|
Some(import_kind) => !query.exclude_import_kinds.contains(&import_kind),
|
||||||
!query.case_sensitive // we've already checked the common importables path case-insensitively
|
None => true,
|
||||||
|
})
|
||||||
|
.filter(|item| {
|
||||||
|
!query.case_sensitive // we've already checked the common importables path case-insensitively
|
||||||
|| query.import_matches(&import_map.map[item], false)
|
|| query.import_matches(&import_map.map[item], false)
|
||||||
});
|
});
|
||||||
res.extend(iter);
|
res.extend(iter);
|
||||||
|
|
||||||
if res.len() >= query.limit {
|
if res.len() >= query.limit {
|
||||||
return res;
|
return res;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue