From 306b100ddaf70b6aa1dae1998bdfb75188a45483 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 00:14:31 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Optimize=20submodule=20lookup=20by?= =?UTF-8?q?=20avoiding=20redundant=20string=20clones?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced inefficient string allocations with `as_deref()` and direct reference lookup. - Avoids `String` allocation when `path` is `Some`. - Avoids eager `clone()` of `name` when `path` is `Some`. - Resulting code is more idiomatic and memory-efficient. Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> --- src/git_ops/git2_ops.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/git_ops/git2_ops.rs b/src/git_ops/git2_ops.rs index bf68695..19b368f 100644 --- a/src/git_ops/git2_ops.rs +++ b/src/git_ops/git2_ops.rs @@ -215,13 +215,7 @@ impl GitOperations for Git2Operations { if let Some(submodules) = config.submodules().as_ref() { for (name, entry) in submodules.iter() { // Find or create the submodule - match self.repo.find_submodule( - &entry - .path - .as_ref() - .map(|p| p.to_string()) - .unwrap_or(name.clone()), - ) { + match self.repo.find_submodule(entry.path.as_deref().unwrap_or(name)) { Ok(mut submodule) => { // Update existing submodule configuration through git config let mut config = self.repo.config()?;