[Mono-devel-list] optimizing foreach on strings (fwd)

Varga Zoltan vargaz at freemail.hu
Sun Mar 30 11:37:21 EST 2003


Miguel de Icaza <miguel at ximian.com> írta:

> 	* There are three tests for this case on the same
> 	  routine that returns, and am confused as to why they are
> 	  needed?  I thought only the first one was required.

The first test skips the GetEnumerator required by
IEnumerable. The
second test is needed since we want to use the MoveNext and 
GetCurrent methods from CharEnumerator and not the ones from
IEnumerator.  The third test is a fix: if the enumerator
does not 
implement IDisposable, the actual type returned by GetEnumerator
might do, so the try-finally can only be optimized away if
the enumerator
type is sealed.

> 	* Could you also improve the regression tests accordingly?



> Miguel.

More information about the Mono-devel-list mailing list