I have a hypothetical question about the efficiency consequences of using exception handling in situations where no exceptions are thrown.
First take a look at this C#:
int simpleSimon, cautiousCarol, dangerousDave;
try
{
simpleSimon = int.Parse("fail");
}
catch
{
simpleSimon = 1;
}
try
{
cautiousCarol = int.Parse("1");
}
catch
{
cautiousCarol = 1;
}
dangerousDave = int.Parse("1");
I am confident that Dave's code will be the fastest/most efficient; while Simon will incur a large penalty for throwing an exception.
But what about Carol? As she throws no exceptions does she incur a penalty? If so, then what kind and how large? (Performance penalty or extra memory usage or anything else?)