Hi,
I was using this tool to fixup some directory casing problems, IE:
git-unite -d
And found that it was very slow progress. This appears to be due to the code for indexEntries being quite slow, as we've 40-50k files in the index, and paths.
I did a bit of an optimization, and altered the code here:
https://github.com/tawman/git-unite/blob/master/src/LibGitUnite/UniteRepository.cs#L156
To
var indexEntries =
_gitRepository.Index.Where(f =>
{
var lastSeparator = f.Path.LastIndexOf(CharSeparator);
if (lastSeparator == -1)
return false;
var directoryPath = f.Path.Substring(0, lastSeparator);
return !foldersFullPathMap.Any(s => s.Contains(directoryPath));
//return f.Path.LastIndexOf(Separator, StringComparison.Ordinal) != -1
// &&
// !foldersFullPathMap.Any(s =>
// s.Contains(f.Path.Substring(0,
// f.Path.LastIndexOf(Separator, StringComparison.Ordinal))));
});
Note that I also added a CharSeparator:
private const char CharSeparator = '\';
Testing on an i9-9900k with ssd, git-unite 2.1 takes 6m25s
With the above optimizations it takes 2m26s. I did wonder if more can be done, eg make the foldersFullPathMap only have the git paths in, rather than the full path.
Still it's a 50% reduction.
Hi,
I was using this tool to fixup some directory casing problems, IE:
git-unite -d
And found that it was very slow progress. This appears to be due to the code for indexEntries being quite slow, as we've 40-50k files in the index, and paths.
I did a bit of an optimization, and altered the code here:
https://github.com/tawman/git-unite/blob/master/src/LibGitUnite/UniteRepository.cs#L156
To
Note that I also added a CharSeparator:
private const char CharSeparator = '\';
Testing on an i9-9900k with ssd, git-unite 2.1 takes 6m25s
With the above optimizations it takes 2m26s. I did wonder if more can be done, eg make the foldersFullPathMap only have the git paths in, rather than the full path.
Still it's a 50% reduction.