I've just replaced this piece of code:
foreach( var source in m_sources )
{
if( !source.IsExhausted )
{
....
}
}
with this one:
foreach( var source in m_sources.Where( src => !src.IsExhausted ) )
{
...
}
Now the code looks better (to me) but I'm wondering what's really happening here. I'm concerned about performance in this case, and it'd be bad news if applying this filter would mean that some kind of compiler magic would take place.
Are the two pieces of code doing basically the 'same' thing? Are temporary containers created to do the filtering then passing them to my foreach?
Any help on the subject will be pretty much appreciated. Thanks.