avoid useless search for non exist files (#967)

This commit is contained in:
Kanglai Qian 2022-05-21 21:10:02 +08:00 committed by VaDiM
parent 220004c976
commit 64d9718c34

View File

@ -17,6 +17,7 @@ namespace AssetStudio
internal Dictionary<string, BinaryReader> resourceFileReaders = new Dictionary<string, BinaryReader>(StringComparer.OrdinalIgnoreCase); internal Dictionary<string, BinaryReader> resourceFileReaders = new Dictionary<string, BinaryReader>(StringComparer.OrdinalIgnoreCase);
private List<string> importFiles = new List<string>(); private List<string> importFiles = new List<string>();
private List<string> noexistFiles = new List<string>();
private HashSet<string> importFilesHash = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private HashSet<string> importFilesHash = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
private HashSet<string> assetsFileListHash = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private HashSet<string> assetsFileListHash = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
@ -54,6 +55,7 @@ namespace AssetStudio
importFiles.Clear(); importFiles.Clear();
importFilesHash.Clear(); importFilesHash.Clear();
noexistFiles.Clear();
assetsFileListHash.Clear(); assetsFileListHash.Clear();
ReadAssets(); ReadAssets();
@ -110,6 +112,8 @@ namespace AssetStudio
if (!importFilesHash.Contains(sharedFileName)) if (!importFilesHash.Contains(sharedFileName))
{ {
var sharedFilePath = Path.Combine(Path.GetDirectoryName(reader.FullPath), sharedFileName); var sharedFilePath = Path.Combine(Path.GetDirectoryName(reader.FullPath), sharedFileName);
if (!noexistFiles.Contains(sharedFilePath))
{
if (!File.Exists(sharedFilePath)) if (!File.Exists(sharedFilePath))
{ {
var findFiles = Directory.GetFiles(Path.GetDirectoryName(reader.FullPath), sharedFileName, SearchOption.AllDirectories); var findFiles = Directory.GetFiles(Path.GetDirectoryName(reader.FullPath), sharedFileName, SearchOption.AllDirectories);
@ -124,6 +128,11 @@ namespace AssetStudio
importFiles.Add(sharedFilePath); importFiles.Add(sharedFilePath);
importFilesHash.Add(sharedFileName); importFilesHash.Add(sharedFileName);
} }
else
{
noexistFiles.Add(sharedFilePath);
}
}
} }
} }
} }