mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 03:45:41 +00:00
perf(sourcegen): cache and compile regex. pass timeout
This commit is contained in:
parent
e3dcad5690
commit
7b9797648a
@ -17,6 +17,7 @@ internal sealed class EmojiRegexGenerator : ISourceGenerator
|
||||
public void Initialize(GeneratorInitializationContext context)
|
||||
{
|
||||
string response = HttpClient.GetStringAsync(TwemojiRegexUrl).GetAwaiter().GetResult();
|
||||
var regex = new Regex(@"export default /(?<regex>.+)/g;", RegexOptions.Compiled, Regex.InfiniteMatchTimeout);
|
||||
using var reader = new StringReader(response);
|
||||
|
||||
while (reader.ReadLine() is { } line)
|
||||
@ -26,7 +27,7 @@ internal sealed class EmojiRegexGenerator : ISourceGenerator
|
||||
continue;
|
||||
}
|
||||
|
||||
Match match = Regex.Match(line, @"export default /(?<regex>.+)/g;");
|
||||
Match match = regex.Match(line);
|
||||
if (!match.Success)
|
||||
{
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user