Skip to content

Commit fa3712d

Browse files
committed
perf(language_server): create less ExternalPluginStores (#14378)
`ExternalPluginStore` is quite a large type. Avoid creating more of them than required.
1 parent 502a2f8 commit fa3712d

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

crates/oxc_language_server/src/linter/server_linter.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,10 @@ impl ServerLinter {
109109

110110
let base_patterns = oxlintrc.ignore_patterns.clone();
111111

112-
let config_builder = ConfigStoreBuilder::from_oxlintrc(
113-
false,
114-
oxlintrc,
115-
None,
116-
&mut ExternalPluginStore::default(),
117-
)
118-
.unwrap_or_default();
112+
let mut external_plugin_store = ExternalPluginStore::default();
113+
let config_builder =
114+
ConfigStoreBuilder::from_oxlintrc(false, oxlintrc, None, &mut external_plugin_store)
115+
.unwrap_or_default();
119116

120117
// TODO(refactor): pull this into a shared function, because in oxlint we have the same functionality.
121118
let use_nested_config = options.use_nested_configs();
@@ -125,7 +122,6 @@ impl ServerLinter {
125122
&& nested_configs.pin().values().any(|config| config.plugins().has_import()));
126123

127124
extended_paths.extend(config_builder.extended_paths.clone());
128-
let external_plugin_store = ExternalPluginStore::default();
129125
let base_config = config_builder.build(&external_plugin_store).unwrap_or_else(|err| {
130126
warn!("Failed to build config: {err}");
131127
ConfigStoreBuilder::empty().build(&external_plugin_store).unwrap()
@@ -152,7 +148,7 @@ impl ServerLinter {
152148
} else {
153149
FxHashMap::default()
154150
},
155-
ExternalPluginStore::default(),
151+
external_plugin_store,
156152
);
157153

158154
let isolated_linter = IsolatedLintHandler::new(
@@ -216,17 +212,17 @@ impl ServerLinter {
216212
};
217213
// Collect ignore patterns and their root
218214
nested_ignore_patterns.push((oxlintrc.ignore_patterns.clone(), dir_path.to_path_buf()));
215+
let mut external_plugin_store = ExternalPluginStore::default();
219216
let Ok(config_store_builder) = ConfigStoreBuilder::from_oxlintrc(
220217
false,
221218
oxlintrc,
222219
None,
223-
&mut ExternalPluginStore::default(),
220+
&mut external_plugin_store,
224221
) else {
225222
warn!("Skipping config (builder failed): {}", file_path.display());
226223
continue;
227224
};
228225
extended_paths.extend(config_store_builder.extended_paths.clone());
229-
let external_plugin_store = ExternalPluginStore::default();
230226
let config = config_store_builder.build(&external_plugin_store).unwrap_or_else(|err| {
231227
warn!("Failed to build nested config for {}: {:?}", dir_path.display(), err);
232228
ConfigStoreBuilder::empty().build(&external_plugin_store).unwrap()

0 commit comments

Comments
 (0)