aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-01-23 11:35:31 +0000
committerGitHub <[email protected]>2020-01-23 11:35:31 +0000
commit8a4c248c48ad7bb9ad556717ee013129c190dbfa (patch)
treed12e106a8fe4b2317d47f0ff727d34d4251fd2f8 /crates/ra_lsp_server/src/main_loop.rs
parent2fb8a461225800ca605a9f2e997cd5e82fb37574 (diff)
parent05aa5b854b230c2f6ba182c0f2c94f3de9a47204 (diff)
Merge #2898
2898: Remove RWLock from check watcher. r=matklad a=kiljacken @matklad mentioned this might be a good idea. So the general idea is that we don't really need the lock, as we can just clone the check watcher state when creating a snapshot. We can then use `Arc::get_mut` to get mutable access to the state from `WorldState` when needed. Running with this it seems to improve responsiveness a bit while cargo is running, but I have no hard numbers to prove it. In any case, a serialization point less is always better when we're trying to be responsive. Co-authored-by: Emil Lauridsen <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop.rs')
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index 7822be2e2..746a8fbe9 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -586,12 +586,14 @@ fn on_notification(
586 586
587fn on_check_task( 587fn on_check_task(
588 task: CheckTask, 588 task: CheckTask,
589 world_state: &WorldState, 589 world_state: &mut WorldState,
590 task_sender: &Sender<Task>, 590 task_sender: &Sender<Task>,
591) -> Result<()> { 591) -> Result<()> {
592 match task { 592 match task {
593 CheckTask::ClearDiagnostics => { 593 CheckTask::ClearDiagnostics => {
594 let cleared_files = world_state.check_watcher.state.write().clear(); 594 let state = Arc::get_mut(&mut world_state.check_watcher.state)
595 .expect("couldn't get check watcher state as mutable");
596 let cleared_files = state.clear();
595 597
596 // Send updated diagnostics for each cleared file 598 // Send updated diagnostics for each cleared file
597 for url in cleared_files { 599 for url in cleared_files {
@@ -600,11 +602,9 @@ fn on_check_task(
600 } 602 }
601 603
602 CheckTask::AddDiagnostic(url, diagnostic) => { 604 CheckTask::AddDiagnostic(url, diagnostic) => {
603 world_state 605 let state = Arc::get_mut(&mut world_state.check_watcher.state)
604 .check_watcher 606 .expect("couldn't get check watcher state as mutable");
605 .state 607 state.add_diagnostic_with_fixes(url.clone(), diagnostic);
606 .write()
607 .add_diagnostic_with_fixes(url.clone(), diagnostic);
608 608
609 // We manually send a diagnostic update when the watcher asks 609 // We manually send a diagnostic update when the watcher asks
610 // us to, to avoid the issue of having to change the file to 610 // us to, to avoid the issue of having to change the file to