Skip to content

Commit

Permalink
Use EnumerationOptions instead of regex matching
Browse files Browse the repository at this point in the history
  • Loading branch information
ScrubN committed Aug 1, 2024
1 parent 07077b0 commit 3b9116d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions TwitchDownloaderCore/TwitchHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -680,13 +680,11 @@ public static async Task<Dictionary<string, SKBitmap>> GetEmojis(string cacheFol
return returnCache;

var emojiFolder = Path.Combine(cacheFolder, "emojis", emojiVendor.EmojiFolder());
var emojiExtensions = new Regex(@"\.(?:png|PNG)$", RegexOptions.RightToLeft); // Extensions are case sensitive on Linux and Mac

if (!Directory.Exists(emojiFolder))
CreateDirectory(emojiFolder);

var emojiFiles = Directory.GetFiles(emojiFolder)
.Where(i => emojiExtensions.IsMatch(i)).ToArray();
var enumerationOptions = new EnumerationOptions { MatchType = MatchType.Simple, MatchCasing = MatchCasing.CaseInsensitive };
var emojiFiles = Directory.GetFiles(emojiFolder, "*.png", enumerationOptions);

if (emojiFiles.Length < emojiVendor.EmojiCount())
{
Expand Down Expand Up @@ -719,8 +717,7 @@ public static async Task<Dictionary<string, SKBitmap>> GetEmojis(string cacheFol
}
}

emojiFiles = Directory.GetFiles(emojiFolder)
.Where(i => emojiExtensions.IsMatch(i)).ToArray();
emojiFiles = Directory.GetFiles(emojiFolder, "*.png", enumerationOptions);
}
finally
{
Expand Down

0 comments on commit 3b9116d

Please sign in to comment.