Is there a chance that C# will optimize the following code block?
if (specField == null || AddSystemType(specField, layout)
|| AddEnumType(specField, layout)
|| AddUserType(specField, layout))
{
}
Well you can use ildasm to see what the compiler has optimized for yourself. But if you were expecting it to remove the code entirely, it can't - because those three method calls could throw exceptions or modify state. So the best it could do would be to emit the equivalent of:
if (specField != null)
{
if (!AddSystemType(specField, layout))
{
if (!AddEnumType(specField, layout))
{
AddUserType(specField, layout);
}
}
}
See more on this question at Stackoverflow