1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-26 14:38:49 +00:00

perf: lazily yield additional value

This prevents an allocation of the array, saving approximately half. Initial benchmarks also show this implementation to be ~100ns faster
This commit is contained in:
Oliver Booth 2023-03-31 15:07:08 +01:00
parent 14e638e6d9
commit d56d12ca23
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025

View File

@ -31,7 +31,12 @@ public static class EnumerableExtensions
}
#endif
return source.Concat(new[] {value});
foreach (TSource item in source)
{
yield return item;
}
yield return value;
}
/// <summary>