Skip to content
This repository was archived by the owner on Feb 12, 2023. It is now read-only.
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Optimize by using a HashSet to lookup valid extensions
  • Loading branch information
raymondwu1 committed Feb 16, 2019
commit 5bbcd480266fff7e30971825f57e3271e38541b5
12 changes: 2 additions & 10 deletions src/GitLink/Linker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static class Linker
private static readonly string PdbStrExePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "pdbstr.exe");
private static readonly string SrcToolExePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "srctool.exe");
private static readonly string[] ExtensionsToIgnore = new string[] { ".g.cs" };
private static readonly HashSet<string> SourceExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { ".cs", ".cpp", ".c", ".cc", ".cxx", ".c++", ".h", ".hh", ".inl", ".hpp" };
private static IReadOnlyList<string> _sourceFilesList = null;

public static bool LinkDirectory(string pdbFolderPath, LinkOptions options = default(LinkOptions))
Expand Down Expand Up @@ -367,16 +368,7 @@ public static Boolean ValidExtension(string sourceFile)
{
var ext = Path.GetExtension(sourceFile);

return string.Equals(ext, ".cs", StringComparison.OrdinalIgnoreCase)
|| string.Equals(ext, ".cpp", StringComparison.OrdinalIgnoreCase)
|| string.Equals(ext, ".c", StringComparison.OrdinalIgnoreCase)
|| string.Equals(ext, ".cc", StringComparison.OrdinalIgnoreCase)
|| string.Equals(ext, ".cxx", StringComparison.OrdinalIgnoreCase)
|| string.Equals(ext, ".c++", StringComparison.OrdinalIgnoreCase)
|| string.Equals(ext, ".h", StringComparison.OrdinalIgnoreCase)
|| string.Equals(ext, ".hh", StringComparison.OrdinalIgnoreCase)
|| string.Equals(ext, ".inl", StringComparison.OrdinalIgnoreCase)
|| string.Equals(ext, ".hpp", StringComparison.OrdinalIgnoreCase);
return SourceExtensions.Contains(ext);
}
}
}