Skip to content

Commit 22ee19f

Browse files
committed
perf(language_server): avoid creating HashMap in Backend::did_change_configuration (#14736)
1 parent ed922ec commit 22ee19f

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

crates/oxc_language_server/src/backend.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,7 @@ impl LanguageServer for Backend {
260260
/// See: <https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_didChangeConfiguration>
261261
async fn did_change_configuration(&self, params: DidChangeConfigurationParams) {
262262
let workers = self.workspace_workers.read().await;
263-
let new_diagnostics: papaya::HashMap<String, Vec<Diagnostic>, FxBuildHasher> =
264-
ConcurrentHashMap::default();
263+
let mut new_diagnostics = Vec::new();
265264
let mut removing_registrations = vec![];
266265
let mut adding_registrations = vec![];
267266

@@ -337,10 +336,10 @@ impl LanguageServer for Backend {
337336

338337
if let Some(diagnostics) = diagnostics {
339338
for (uri, reports) in &diagnostics.pin() {
340-
new_diagnostics.pin().insert(
339+
new_diagnostics.push((
341340
uri.clone(),
342341
reports.iter().map(|d| d.diagnostic.clone()).collect(),
343-
);
342+
));
344343
}
345344
}
346345

@@ -364,13 +363,7 @@ impl LanguageServer for Backend {
364363
}
365364

366365
if !new_diagnostics.is_empty() {
367-
let x = &new_diagnostics
368-
.pin()
369-
.into_iter()
370-
.map(|(key, value)| (key.clone(), value.clone()))
371-
.collect::<Vec<_>>();
372-
373-
self.publish_all_diagnostics(x).await;
366+
self.publish_all_diagnostics(&new_diagnostics).await;
374367
}
375368

376369
// override the existing formatting registration

0 commit comments

Comments
 (0)