Skip to content

Commit e76e0e8

Browse files
committed
Simplify
1 parent 0b1c434 commit e76e0e8

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

crates/hir_def/src/import_map.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,29 +72,33 @@ impl ImportMap {
7272

7373
let mut import_map = collect_import_map(db, krate);
7474

75-
let mut importables = import_map.map.iter().collect::<Vec<_>>();
76-
importables.sort_by_cached_key(|(_, import_info)| fst_path(&import_info.path));
75+
let mut importables = import_map
76+
.map
77+
.iter()
78+
.map(|(item, info)| (item, fst_path(&info.path)))
79+
.collect::<Vec<_>>();
80+
importables.sort_by(|(_, fst_path), (_, fst_path2)| fst_path.cmp(fst_path2));
7781

7882
// Build the FST, taking care not to insert duplicate values.
7983

8084
let mut builder = fst::MapBuilder::memory();
8185
let mut last_batch_start = 0;
8286

8387
for idx in 0..importables.len() {
84-
let key = fst_path(&importables[last_batch_start].1.path);
85-
if let Some((_, next_import_info)) = importables.get(idx + 1) {
86-
if key == fst_path(&next_import_info.path) {
88+
let key = &importables[last_batch_start].1;
89+
if let Some((_, fst_path)) = importables.get(idx + 1) {
90+
if key == fst_path {
8791
continue;
8892
}
8993
}
9094

91-
builder.insert(key, last_batch_start as u64).unwrap();
95+
let _ = builder.insert(key, last_batch_start as u64);
9296

9397
last_batch_start = idx + 1;
9498
}
9599

96-
import_map.fst = fst::Map::new(builder.into_inner().unwrap()).unwrap();
97-
import_map.importables = importables.iter().map(|(item, _)| **item).collect();
100+
import_map.fst = builder.into_map();
101+
import_map.importables = importables.iter().map(|&(&item, _)| item).collect();
98102

99103
Arc::new(import_map)
100104
}

crates/ide_completion/src/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ impl<'a> CompletionContext<'a> {
302302

303303
/// A version of [`SemanticsScope::process_all_names`] that filters out `#[doc(hidden)]` items.
304304
pub(crate) fn process_all_names(&self, f: &mut dyn FnMut(Name, ScopeDef)) {
305+
let _p = profile::span("CompletionContext::process_all_names");
305306
self.scope.process_all_names(&mut |name, def| {
306307
if self.is_scope_def_hidden(def) {
307308
return;
@@ -422,6 +423,7 @@ impl<'a> CompletionContext<'a> {
422423
mut offset: TextSize,
423424
mut fake_ident_token: SyntaxToken,
424425
) {
426+
let _p = profile::span("CompletionContext::expand_and_fill");
425427
loop {
426428
// Expand attributes
427429
if let (Some(actual_item), Some(item_with_fake_ident)) = (

0 commit comments

Comments
 (0)