Hi Michael,

Sorry, the text is indeed misleading. This is a much simpler, easier to understand version.

The code you highlight from System.Linq can be resumed to, Enumerable.Empty() returns a reference to an Array with zero items. What you don’t see there is that, when enumerating, the Array.GetEnumerator() is called. This returns an new instance of SZArrayEnumerator, which allocates more memory because it’s a class and has three fields. Its MoveNext() implementation has to compare the current and the end positions to return false.

That implementation is all over the place and has worst performance… ;)

Thanks a lot for the feedback!

Principal Engineer @ Farfetch - Future Retail Lab https://about.me/antao.almada

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store