File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,8 @@ impl TsGoLintState {
9292 let mut buffer = Vec :: with_capacity ( 8192 ) ;
9393 let mut read_buf = [ 0u8 ; 8192 ] ;
9494
95+ let mut source_text_map: FxHashMap < PathBuf , String > = FxHashMap :: default ( ) ;
96+
9597 loop {
9698 match stdout. read ( & mut read_buf) {
9799 Ok ( 0 ) => break , // EOF
@@ -145,11 +147,23 @@ impl TsGoLintState {
145147 } ,
146148 ) ;
147149
150+ let source_text: & str =
151+ if let Some ( source_text) = source_text_map. get ( & path) {
152+ source_text. as_str ( )
153+ } else {
154+ let source_text = read_to_string ( & path)
155+ . unwrap_or_else ( |_| String :: new ( ) ) ;
156+ // Insert and get a reference to the inserted string
157+ let entry = source_text_map
158+ . entry ( path. clone ( ) )
159+ . or_insert ( source_text) ;
160+ entry. as_str ( )
161+ } ;
162+
148163 let diagnostics = DiagnosticService :: wrap_diagnostics (
149164 cwd_clone. clone ( ) ,
150165 path. clone ( ) ,
151- & read_to_string ( & path)
152- . unwrap_or_else ( |_| String :: new ( ) ) ,
166+ source_text,
153167 vec ! [ oxc_diagnostic] ,
154168 ) ;
155169
You can’t perform that action at this time.
0 commit comments