@@ -72,29 +72,33 @@ impl ImportMap {
72
72
73
73
let mut import_map = collect_import_map ( db, krate) ;
74
74
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) ) ;
77
81
78
82
// Build the FST, taking care not to insert duplicate values.
79
83
80
84
let mut builder = fst:: MapBuilder :: memory ( ) ;
81
85
let mut last_batch_start = 0 ;
82
86
83
87
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 {
87
91
continue ;
88
92
}
89
93
}
90
94
91
- builder. insert ( key, last_batch_start as u64 ) . unwrap ( ) ;
95
+ let _ = builder. insert ( key, last_batch_start as u64 ) ;
92
96
93
97
last_batch_start = idx + 1 ;
94
98
}
95
99
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 ( ) ;
98
102
99
103
Arc :: new ( import_map)
100
104
}
0 commit comments