@@ -75,7 +75,7 @@ impl flags::Scip {
7575 let mut symbols_emitted: HashSet < TokenId > = HashSet :: default ( ) ;
7676 let mut tokens_to_symbol: HashMap < TokenId , String > = HashMap :: new ( ) ;
7777
78- for file in si. files {
78+ for StaticIndexedFile { file_id , tokens , .. } in si. files {
7979 let mut local_count = 0 ;
8080 let mut new_local_symbol = || {
8181 let new_symbol = scip:: types:: Symbol :: new_local ( local_count) ;
@@ -84,7 +84,6 @@ impl flags::Scip {
8484 new_symbol
8585 } ;
8686
87- let StaticIndexedFile { file_id, tokens, .. } = file;
8887 let relative_path = match get_relative_filepath ( & vfs, & rootpath, file_id) {
8988 Some ( relative_path) => relative_path,
9089 None => continue ,
@@ -107,28 +106,23 @@ impl flags::Scip {
107106
108107 let mut occurrence = scip_types:: Occurrence :: default ( ) ;
109108 occurrence. range = text_range_to_scip_range ( & line_index, range) ;
110- occurrence. symbol = match tokens_to_symbol. get ( & id ) {
111- Some ( symbol ) => symbol . clone ( ) ,
112- None => {
109+ occurrence. symbol = tokens_to_symbol
110+ . entry ( id )
111+ . or_insert_with ( || {
113112 let symbol = match & token. moniker {
114113 Some ( moniker) => moniker_to_symbol ( & moniker) ,
115114 None => new_local_symbol ( ) ,
116115 } ;
117-
118- let symbol = scip:: symbol:: format_symbol ( symbol) ;
119- tokens_to_symbol. insert ( id, symbol. clone ( ) ) ;
120- symbol
121- }
122- } ;
116+ scip:: symbol:: format_symbol ( symbol)
117+ } )
118+ . clone ( ) ;
123119
124120 if let Some ( def) = token. definition {
125121 if def. range == range {
126122 occurrence. symbol_roles |= scip_types:: SymbolRole :: Definition as i32 ;
127123 }
128124
129- if !symbols_emitted. contains ( & id) {
130- symbols_emitted. insert ( id) ;
131-
125+ if symbols_emitted. insert ( id) {
132126 let mut symbol_info = scip_types:: SymbolInformation :: default ( ) ;
133127 symbol_info. symbol = occurrence. symbol . clone ( ) ;
134128 if let Some ( hover) = & token. hover {
0 commit comments