I stuck in mscorlib to find out how the generic collection optimized their counts, and I came across this:
public bool MoveNext()
{
List<T> list = this.list;
if ((this.version == list._version) && (this.index < list._size))
{
this.current = list._items[this.index];
this.index++;
return true;
}
return this.MoveNextRare();
}
The stack size is 3, and the bytecode size must be 80 bytes. The naming of the method MoveNextRarehelped me on the toes, and there is a case with an error in it, as well as an empty case with an assembly, so obviously this violates the separation of concern.
I guess the method is MoveNextbroken down in such a way as to optimize the stack space and help JIT, and I would like to do the same for some of my bottlenecks, but without hard data I don't want my voodoo programming turning into a load-cult ;)
Thank! Florian