mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Use SearchOption.AllDirectories and EnumerateFiles
Avoids unnecessary allocations (arrays and LINQ) and allows enumerating through the results immediately without having to wait for arrays to be allocated, filled, and returned.
This commit is contained in:
@@ -23,18 +23,14 @@ namespace Squirrel
|
||||
{
|
||||
Contract.Requires(rootPath != null);
|
||||
|
||||
return rootPath.GetDirectories()
|
||||
.SelectMany(GetAllFilesRecursively)
|
||||
.Concat(rootPath.GetFiles());
|
||||
return rootPath.EnumerateFiles("*", SearchOption.AllDirectories);
|
||||
}
|
||||
|
||||
public static IEnumerable<string> GetAllFilePathsRecursively(string rootPath)
|
||||
{
|
||||
Contract.Requires(rootPath != null);
|
||||
|
||||
return Directory.GetDirectories(rootPath)
|
||||
.SelectMany(GetAllFilePathsRecursively)
|
||||
.Concat(Directory.GetFiles(rootPath));
|
||||
return Directory.EnumerateFiles(rootPath, "*", SearchOption.AllDirectories);
|
||||
}
|
||||
|
||||
public static string CalculateFileSHA1(string filePath)
|
||||
|
||||
Reference in New Issue
Block a user