Switch from Arc/RwLock to Rc/RefCell for CodeContextMenu (#22035)
`CodeContextMenu` is always accessed on one thread, so only `Rc`s and `Rc<RefCell<_>>` are needed. There should be tiny performance benefits from this. The main benefit of this is that when seeing code accessing a `RwLock` it would be reasonable to wonder whether it will block. The only potential downside is the potential for panics due to overlapping borrows of the RefCells. I think this is an acceptable risk because most errors of this nature will be local or will be caught by clippy via the check for holding a RefCell reference over an `await`. Release Notes: - N/A
This commit is contained in:
parent
7b721efe2c
commit
a94afbc062
12 changed files with 108 additions and 93 deletions
|
@ -57,7 +57,7 @@ use lsp::{
|
|||
};
|
||||
use lsp_command::*;
|
||||
use node_runtime::NodeRuntime;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use parking_lot::Mutex;
|
||||
pub use prettier_store::PrettierStore;
|
||||
use project_settings::{ProjectSettings, SettingsObserver, SettingsObserverEvent};
|
||||
use remote::{SshConnectionOptions, SshRemoteClient};
|
||||
|
@ -73,8 +73,10 @@ use snippet::Snippet;
|
|||
use snippet_provider::SnippetProvider;
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
cell::RefCell,
|
||||
ops::Range,
|
||||
path::{Component, Path, PathBuf},
|
||||
rc::Rc,
|
||||
str,
|
||||
sync::Arc,
|
||||
time::Duration,
|
||||
|
@ -2872,7 +2874,7 @@ impl Project {
|
|||
&self,
|
||||
buffer: Model<Buffer>,
|
||||
completion_indices: Vec<usize>,
|
||||
completions: Arc<RwLock<Box<[Completion]>>>,
|
||||
completions: Rc<RefCell<Box<[Completion]>>>,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Task<Result<bool>> {
|
||||
self.lsp_store.update(cx, |lsp_store, cx| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue