1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-09 23:45:42 +00:00

perf: exit early if TryGetNonEnumeratedCount is 0

This commit is contained in:
Oliver Booth 2023-03-30 20:56:34 +01:00
parent f30c052673
commit f360311d9c
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025

View File

@ -65,6 +65,13 @@ public static class EnumerableExtensions
}
#endif
#if NET6_0_OR_GREATER
if (source.TryGetNonEnumeratedCount(out int count) && count == 0)
{
yield break;
}
#endif
var regex = new Regex(pattern, RegexOptions.Compiled | (ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None));
foreach (string item in source)