Reduce array allocations

This commit is contained in:
Matt Nadareski
2024-10-24 05:33:28 -04:00
parent e992f0d013
commit 15e30d7a75
6 changed files with 21 additions and 13 deletions

View File

@@ -58,6 +58,7 @@ have a current entry in the DAT index.";
// Get feature flags
bool noDb = GetBoolean(features, NoDbValue);
bool onlyNeeded = GetBoolean(features, OnlyNeededValue);
HashType[] hashes = [HashType.CRC32, HashType.MD5, HashType.SHA1];
// First we want to get just all directories from the inputs
List<string> onlyDirs = [];
@@ -71,8 +72,8 @@ have a current entry in the DAT index.";
DatFile df = DatFile.Create();
foreach (string dir in onlyDirs)
{
DatFromDir.PopulateFromDir(df, dir, asFiles: TreatAsFile.NonArchive, hashes: [HashType.CRC32, HashType.MD5, HashType.SHA1]);
DatFromDir.PopulateFromDir(df, dir, asFiles: TreatAsFile.All, hashes: [HashType.CRC32, HashType.MD5, HashType.SHA1]);
DatFromDir.PopulateFromDir(df, dir, asFiles: TreatAsFile.NonArchive, hashes: hashes);
DatFromDir.PopulateFromDir(df, dir, asFiles: TreatAsFile.All, hashes: hashes);
}
// Create an empty Dat for files that need to be rebuilt