zed: Remove unnecessary clones (#29513)

tidely created

`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

Change summary

crates/agent/src/buffer_codegen.rs                      | 2 +-
crates/agent/src/context_picker/completion_provider.rs  | 2 +-
crates/agent/src/context_picker/fetch_context_picker.rs | 2 +-
crates/assistant/src/inline_assistant.rs                | 2 +-
crates/assistant_context_editor/src/context_editor.rs   | 2 +-
crates/assistant_slash_commands/src/docs_command.rs     | 2 +-
crates/eval/src/eval.rs                                 | 6 +++---
crates/extension_host/src/extension_host.rs             | 4 ++--
crates/zed/src/main.rs                                  | 2 +-
crates/zed/src/zed.rs                                   | 6 +-----
10 files changed, 13 insertions(+), 17 deletions(-)

Detailed changes

crates/agent/src/buffer_codegen.rs 🔗

@@ -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 language_name = {
             let multibuffer = self.buffer.read(cx);

crates/agent/src/context_picker/completion_provider.rs 🔗

@@ -708,7 +708,7 @@ impl CompletionProvider for ContextPickerCompletionProvider {
 
         let thread_store = self.thread_store.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 query = argument.unwrap_or_else(|| "".to_string());

crates/agent/src/context_picker/fetch_context_picker.rs 🔗

@@ -193,7 +193,7 @@ impl PickerDelegate for FetchContextPickerDelegate {
             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();
         cx.spawn_in(window, async move |this, cx| {
             let text = cx

crates/assistant/src/inline_assistant.rs 🔗

@@ -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 language_name = {
             let multibuffer = self.buffer.read(cx);

crates/assistant_context_editor/src/context_editor.rs 🔗

@@ -3768,7 +3768,7 @@ pub fn make_lsp_adapter_delegate(
         let Some(worktree) = project.worktrees(cx).next() else {
             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| {
             Ok(Some(LocalLspAdapterDelegate::new(
                 project.languages().clone(),

crates/assistant_slash_commands/src/docs_command.rs 🔗

@@ -83,7 +83,7 @@ impl DocsSlashCommand {
                     .upgrade()
                     .ok_or_else(|| anyhow!("workspace was dropped"))?;
                 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() {

crates/eval/src/eval.rs 🔗

@@ -371,7 +371,7 @@ pub fn init(cx: &mut App) -> Arc<AgentAppState> {
     Project::init_settings(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 fs = Arc::new(RealFs::new(
@@ -411,7 +411,7 @@ pub fn init(cx: &mut App) -> Arc<AgentAppState> {
         tx.send(Some(options)).log_err();
     })
     .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);
 
@@ -420,7 +420,7 @@ pub fn init(cx: &mut App) -> Arc<AgentAppState> {
     language_model::init(client.clone(), cx);
     language_models::init(user_store.clone(), client.clone(), fs.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);
     prompt_store::init(cx);
     let stdout_is_a_pty = false;

crates/extension_host/src/extension_host.rs 🔗

@@ -193,8 +193,8 @@ pub fn init(
             None,
             extension_host_proxy,
             fs,
-            client.http_client().clone(),
-            client.http_client().clone(),
+            client.http_client(),
+            client.http_client(),
             Some(client.telemetry().clone()),
             node_runtime,
             cx,

crates/zed/src/main.rs 🔗

@@ -378,7 +378,7 @@ fn main() {
         let extension_host_proxy = ExtensionHostProxy::global(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());
         languages.set_language_server_download_dir(paths::languages_dir().clone());
         let languages = Arc::new(languages);

crates/zed/src/zed.rs 🔗

@@ -4245,11 +4245,7 @@ mod tests {
             project_panel::init(cx);
             outline_panel::init(cx);
             terminal_view::init(cx);
-            copilot::copilot_chat::init(
-                app_state.fs.clone(),
-                app_state.client.http_client().clone(),
-                cx,
-            );
+            copilot::copilot_chat::init(app_state.fs.clone(), app_state.client.http_client(), cx);
             image_viewer::init(cx);
             language_model::init(app_state.client.clone(), cx);
             language_models::init(