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,
git_repo: &git2::Repository,
remote_name: &str,
globs: &[String],
globs: &[&str],
callbacks: RemoteCallbacks<'_>,
git_settings: &GitSettings,
) -> Result<Option<String>, GitFetchError> {

View File

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