mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-23 00:58:48 +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:
parent
14e638e6d9
commit
d56d12ca23
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user