Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 4fb1bc6

Browse files
committed
🎨 Micro optimization create needed services
The prior code always created a `IGitService` instance, but we only need to create them if there are any active repositories. Also changed to use `.Any()` because it is more expressive.
1 parent 0941a90 commit 4fb1bc6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/GitHub.Exports/Services/VSServices.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,15 @@ public void Clone(string cloneUrl, string clonePath, bool recurseSubmodules)
7676
public LibGit2Sharp.IRepository GetActiveRepo()
7777
{
7878
var gitExt = serviceProvider.GetService<IGitExt>();
79-
var gitService = serviceProvider.GetService<IGitService>();
80-
if (gitExt.ActiveRepositories.Count > 0)
81-
return gitService.GetRepo(gitExt.ActiveRepositories.First());
82-
return serviceProvider.GetSolution().GetRepoFromSolution();
79+
return gitExt.ActiveRepositories.Any()
80+
? serviceProvider.GetService<IGitService>().GetRepo(gitExt.ActiveRepositories.First())
81+
: serviceProvider.GetSolution().GetRepoFromSolution();
8382
}
8483

8584
public string GetActiveRepoPath()
8685
{
8786
var gitExt = serviceProvider.GetService<IGitExt>();
88-
if (gitExt.ActiveRepositories.Count > 0)
87+
if (gitExt.ActiveRepositories.Any())
8988
return gitExt.ActiveRepositories.First().RepositoryPath;
9089
var repo = serviceProvider.GetSolution().GetRepoFromSolution();
9190
return repo?.Info?.Path ?? string.Empty;

0 commit comments

Comments
 (0)