git: use &[&str] instead of &[String]

Using &[String] forces the caller to materalize owned strings if they
have only references, which is costly. Using &[&str] makes it cheap
if the caller owns strings as well.
This commit is contained in:
Samuel Tardieu 2023-02-26 15:23:04 +01:00
parent 681944954e
commit 6fd65cca30
2 changed files with 3 additions and 2 deletions

View File

@ -342,7 +342,7 @@ pub fn fetch(
mut_repo: &mut MutableRepo, mut_repo: &mut MutableRepo,
git_repo: &git2::Repository, git_repo: &git2::Repository,
remote_name: &str, remote_name: &str,
globs: &[String], globs: &[&str],
callbacks: RemoteCallbacks<'_>, callbacks: RemoteCallbacks<'_>,
git_settings: &GitSettings, git_settings: &GitSettings,
) -> Result<Option<String>, GitFetchError> { ) -> Result<Option<String>, GitFetchError> {

View File

@ -295,13 +295,14 @@ fn cmd_git_fetch(
"fetch from git remote(s) {}", "fetch from git remote(s) {}",
remotes.iter().join(",") remotes.iter().join(",")
)); ));
let branches = args.branch.iter().map(|b| b.as_str()).collect_vec();
for remote in remotes { for remote in remotes {
with_remote_callbacks(ui, |cb| { with_remote_callbacks(ui, |cb| {
git::fetch( git::fetch(
tx.mut_repo(), tx.mut_repo(),
&git_repo, &git_repo,
&remote, &remote,
&args.branch, &branches,
cb, cb,
&command.settings().git_settings(), &command.settings().git_settings(),
) )