zed: Remove unnecessary clones (#29513)
`App::http_client` and `Client::http_client` both return an owned `Arc` which it clones internally. This means we can remove unnecessary clones when calling these methods. Release Notes: - N/A
This commit is contained in:
parent
609c528ceb
commit
f060918b57
10 changed files with 13 additions and 17 deletions
|
@ -503,7 +503,7 @@ impl CodegenAlternative {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let http_client = cx.http_client().clone();
|
let http_client = cx.http_client();
|
||||||
let telemetry = self.telemetry.clone();
|
let telemetry = self.telemetry.clone();
|
||||||
let language_name = {
|
let language_name = {
|
||||||
let multibuffer = self.buffer.read(cx);
|
let multibuffer = self.buffer.read(cx);
|
||||||
|
|
|
@ -708,7 +708,7 @@ impl CompletionProvider for ContextPickerCompletionProvider {
|
||||||
|
|
||||||
let thread_store = self.thread_store.clone();
|
let thread_store = self.thread_store.clone();
|
||||||
let editor = self.editor.clone();
|
let editor = self.editor.clone();
|
||||||
let http_client = workspace.read(cx).client().http_client().clone();
|
let http_client = workspace.read(cx).client().http_client();
|
||||||
|
|
||||||
let MentionCompletion { mode, argument, .. } = state;
|
let MentionCompletion { mode, argument, .. } = state;
|
||||||
let query = argument.unwrap_or_else(|| "".to_string());
|
let query = argument.unwrap_or_else(|| "".to_string());
|
||||||
|
|
|
@ -193,7 +193,7 @@ impl PickerDelegate for FetchContextPickerDelegate {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let http_client = workspace.read(cx).client().http_client().clone();
|
let http_client = workspace.read(cx).client().http_client();
|
||||||
let url = self.url.clone();
|
let url = self.url.clone();
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
let text = cx
|
let text = cx
|
||||||
|
|
|
@ -3023,7 +3023,7 @@ impl CodegenAlternative {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let http_client = cx.http_client().clone();
|
let http_client = cx.http_client();
|
||||||
let telemetry = self.telemetry.clone();
|
let telemetry = self.telemetry.clone();
|
||||||
let language_name = {
|
let language_name = {
|
||||||
let multibuffer = self.buffer.read(cx);
|
let multibuffer = self.buffer.read(cx);
|
||||||
|
|
|
@ -3768,7 +3768,7 @@ pub fn make_lsp_adapter_delegate(
|
||||||
let Some(worktree) = project.worktrees(cx).next() else {
|
let Some(worktree) = project.worktrees(cx).next() else {
|
||||||
return Ok(None::<Arc<dyn LspAdapterDelegate>>);
|
return Ok(None::<Arc<dyn LspAdapterDelegate>>);
|
||||||
};
|
};
|
||||||
let http_client = project.client().http_client().clone();
|
let http_client = project.client().http_client();
|
||||||
project.lsp_store().update(cx, |_, cx| {
|
project.lsp_store().update(cx, |_, cx| {
|
||||||
Ok(Some(LocalLspAdapterDelegate::new(
|
Ok(Some(LocalLspAdapterDelegate::new(
|
||||||
project.languages().clone(),
|
project.languages().clone(),
|
||||||
|
|
|
@ -83,7 +83,7 @@ impl DocsSlashCommand {
|
||||||
.upgrade()
|
.upgrade()
|
||||||
.ok_or_else(|| anyhow!("workspace was dropped"))?;
|
.ok_or_else(|| anyhow!("workspace was dropped"))?;
|
||||||
let project = workspace.read(cx).project().clone();
|
let project = workspace.read(cx).project().clone();
|
||||||
anyhow::Ok(project.read(cx).client().http_client().clone())
|
anyhow::Ok(project.read(cx).client().http_client())
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(http_client) = http_client.log_err() {
|
if let Some(http_client) = http_client.log_err() {
|
||||||
|
|
|
@ -371,7 +371,7 @@ pub fn init(cx: &mut App) -> Arc<AgentAppState> {
|
||||||
Project::init_settings(cx);
|
Project::init_settings(cx);
|
||||||
|
|
||||||
let client = Client::production(cx);
|
let client = Client::production(cx);
|
||||||
cx.set_http_client(client.http_client().clone());
|
cx.set_http_client(client.http_client());
|
||||||
|
|
||||||
let git_binary_path = None;
|
let git_binary_path = None;
|
||||||
let fs = Arc::new(RealFs::new(
|
let fs = Arc::new(RealFs::new(
|
||||||
|
@ -411,7 +411,7 @@ pub fn init(cx: &mut App) -> Arc<AgentAppState> {
|
||||||
tx.send(Some(options)).log_err();
|
tx.send(Some(options)).log_err();
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
let node_runtime = NodeRuntime::new(client.http_client().clone(), rx);
|
let node_runtime = NodeRuntime::new(client.http_client(), rx);
|
||||||
|
|
||||||
let extension_host_proxy = ExtensionHostProxy::global(cx);
|
let extension_host_proxy = ExtensionHostProxy::global(cx);
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@ pub fn init(cx: &mut App) -> Arc<AgentAppState> {
|
||||||
language_model::init(client.clone(), cx);
|
language_model::init(client.clone(), cx);
|
||||||
language_models::init(user_store.clone(), client.clone(), fs.clone(), cx);
|
language_models::init(user_store.clone(), client.clone(), fs.clone(), cx);
|
||||||
languages::init(languages.clone(), node_runtime.clone(), cx);
|
languages::init(languages.clone(), node_runtime.clone(), cx);
|
||||||
assistant_tools::init(client.http_client().clone(), cx);
|
assistant_tools::init(client.http_client(), cx);
|
||||||
context_server::init(cx);
|
context_server::init(cx);
|
||||||
prompt_store::init(cx);
|
prompt_store::init(cx);
|
||||||
let stdout_is_a_pty = false;
|
let stdout_is_a_pty = false;
|
||||||
|
|
|
@ -193,8 +193,8 @@ pub fn init(
|
||||||
None,
|
None,
|
||||||
extension_host_proxy,
|
extension_host_proxy,
|
||||||
fs,
|
fs,
|
||||||
client.http_client().clone(),
|
client.http_client(),
|
||||||
client.http_client().clone(),
|
client.http_client(),
|
||||||
Some(client.telemetry().clone()),
|
Some(client.telemetry().clone()),
|
||||||
node_runtime,
|
node_runtime,
|
||||||
cx,
|
cx,
|
||||||
|
|
|
@ -378,7 +378,7 @@ fn main() {
|
||||||
let extension_host_proxy = ExtensionHostProxy::global(cx);
|
let extension_host_proxy = ExtensionHostProxy::global(cx);
|
||||||
|
|
||||||
let client = Client::production(cx);
|
let client = Client::production(cx);
|
||||||
cx.set_http_client(client.http_client().clone());
|
cx.set_http_client(client.http_client());
|
||||||
let mut languages = LanguageRegistry::new(cx.background_executor().clone());
|
let mut languages = LanguageRegistry::new(cx.background_executor().clone());
|
||||||
languages.set_language_server_download_dir(paths::languages_dir().clone());
|
languages.set_language_server_download_dir(paths::languages_dir().clone());
|
||||||
let languages = Arc::new(languages);
|
let languages = Arc::new(languages);
|
||||||
|
|
|
@ -4245,11 +4245,7 @@ mod tests {
|
||||||
project_panel::init(cx);
|
project_panel::init(cx);
|
||||||
outline_panel::init(cx);
|
outline_panel::init(cx);
|
||||||
terminal_view::init(cx);
|
terminal_view::init(cx);
|
||||||
copilot::copilot_chat::init(
|
copilot::copilot_chat::init(app_state.fs.clone(), app_state.client.http_client(), cx);
|
||||||
app_state.fs.clone(),
|
|
||||||
app_state.client.http_client().clone(),
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
image_viewer::init(cx);
|
image_viewer::init(cx);
|
||||||
language_model::init(app_state.client.clone(), cx);
|
language_model::init(app_state.client.clone(), cx);
|
||||||
language_models::init(
|
language_models::init(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue