Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 292cb5b

Browse files
committed
Optimise mutex locking when reading initial configuration
* Remove commented out test line
1 parent ea98476 commit 292cb5b

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/actions/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,16 @@ impl InitActionContext {
309309
fn init<O: Output>(&self, init_options: InitializationOptions, out: &O) {
310310
let current_project = self.current_project.clone();
311311

312-
if let Some(config) = init_options.settings.map(|s| s.rust) {
313-
self.config.lock().unwrap().update(config);
314-
}
312+
let needs_inference = {
313+
let mut config = self.config.lock().unwrap();
314+
315+
if let Some(init_config) = init_options.settings.map(|s| s.rust) {
316+
config.update(init_config);
317+
}
318+
config.needs_inference()
319+
};
315320

316-
if self.config.lock().unwrap().needs_inference() {
321+
if needs_inference {
317322
let config = Arc::clone(&self.config);
318323
// Spawn another thread since we're shelling out to Cargo and this can
319324
// cause a non-trivial amount of time due to disk access

src/test/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ fn initialize_with_opts(
4242
root_path: Option<String>,
4343
initialization_options: Option<serde_json::Value>,
4444
) -> Request<ls_server::InitializeRequest> {
45-
// let init_opts = initialization_options.map(|val| serde_json::to_value(val).unwrap());
4645
let params = InitializeParams {
4746
process_id: None,
4847
root_path,

0 commit comments

Comments
 (0)