Skip to content

Commit

Permalink
Merge pull request #827: Improve perf of prefetch when using large --…
Browse files Browse the repository at this point in the history
…files-list
  • Loading branch information
jrbriggs committed Feb 23, 2019
2 parents d052483 + c772bb4 commit e6fcae7
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions GVFS/GVFS.Common/Prefetch/Git/DiffHelper.cs
Expand Up @@ -5,23 +5,24 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;


namespace GVFS.Common.Prefetch.Git
{
public class DiffHelper
{
private const string AreaPath = nameof(DiffHelper);

private ITracer tracer;
private List<string> fileList;
private HashSet<string> exactFileList;
private List<string> patternList;
private List<string> folderList;
private HashSet<string> filesAdded = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

private HashSet<DiffTreeResult> stagedDirectoryOperations = new HashSet<DiffTreeResult>(new DiffTreeByNameComparer());
private HashSet<string> stagedFileDeletes = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

private Enlistment enlistment;
private GitProcess git;
private GitProcess git;

public DiffHelper(ITracer tracer, Enlistment enlistment, IEnumerable<string> fileList, IEnumerable<string> folderList, bool includeSymLinks)
: this(tracer, enlistment, new GitProcess(enlistment), fileList, folderList, includeSymLinks)
Expand All @@ -31,7 +32,8 @@ public DiffHelper(ITracer tracer, Enlistment enlistment, IEnumerable<string> fil
public DiffHelper(ITracer tracer, Enlistment enlistment, GitProcess git, IEnumerable<string> fileList, IEnumerable<string> folderList, bool includeSymLinks)
{
this.tracer = tracer;
this.fileList = new List<string>(fileList);
this.exactFileList = new HashSet<string>(fileList.Where(x => !x.StartsWith("*")), StringComparer.OrdinalIgnoreCase);
this.patternList = fileList.Where(x => x.StartsWith("*")).ToList();
this.folderList = new List<string>(folderList);
this.enlistment = enlistment;
this.git = git;
Expand All @@ -41,8 +43,8 @@ public DiffHelper(ITracer tracer, Enlistment enlistment, GitProcess git, IEnumer
this.FileDeleteOperations = new ConcurrentQueue<string>();
this.FileAddOperations = new ConcurrentDictionary<string, HashSet<PathWithMode>>(StringComparer.OrdinalIgnoreCase);
this.RequiredBlobs = new BlockingCollection<string>();
}

}

public bool ShouldIncludeSymLinks { get; set; }

public bool HasFailures { get; private set; }
Expand Down Expand Up @@ -325,15 +327,15 @@ private bool ShouldIncludeResult(DiffTreeResult blobAdd)
return true;
}

if (this.fileList.Count == 0 && this.folderList.Count == 0)
if (this.exactFileList.Count == 0 &&
this.patternList.Count == 0 &&
this.folderList.Count == 0)
{
return true;
}

if (this.fileList.Any(path =>
path.StartsWith("*")
? blobAdd.TargetPath.EndsWith(path.Substring(1), StringComparison.OrdinalIgnoreCase)
: blobAdd.TargetPath.Equals(path, StringComparison.OrdinalIgnoreCase)))
if (this.exactFileList.Contains(blobAdd.TargetPath) ||
this.patternList.Any(path => blobAdd.TargetPath.EndsWith(path.Substring(1), StringComparison.OrdinalIgnoreCase)))
{
return true;
}
Expand Down

0 comments on commit e6fcae7

Please sign in to comment.