Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 5871a87

Browse files
Using a HashSet at the right time.
Method | Mean | Error | StdDev | ----------------------------- |---------:|----------:|----------:| OriginalTreeBuilderBenchmark | 61.32 ms | 0.8018 ms | 0.7500 ms | CurrentTreeBuilderBenchmark | 42.24 ms | 0.8295 ms | 1.0786 ms |
1 parent 7a5c16d commit 5871a87

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/GitHub.Api/UI/TreeBuilder.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,12 @@ internal static FileTreeNode BuildTreeRoot(IList<GitStatusEntry> newEntries, Lis
7676
{
7777
Guard.ArgumentNotNullOrEmpty(newEntries, "newEntries");
7878

79+
var newEntriesSetByPath = new HashSet<string>(newEntries.Select(entry => entry.Path));
80+
7981
// Remove what got nuked
8082
for (var index = 0; index < gitStatusEntries.Count;)
8183
{
82-
if (!newEntries.Contains(gitStatusEntries[index]))
84+
if (!newEntriesSetByPath.Contains(gitStatusEntries[index].Path))
8385
{
8486
gitStatusEntries.RemoveAt(index);
8587
gitCommitTargets.RemoveAt(index);

0 commit comments

Comments
 (0)