4 ms·
>> And if the exception can be expected to trigger with sufficient frequency But if this is the case, it can be said that the exception handler code should be
by greyman 15y ago
>> And if the exception can be expected to trigger with sufficient frequency
But if this is the case, it can be said that the exception handler code should be a part of a normal code flow - it's generally wrong to use exception mechanism when it is expected that the code will be executed regularly. Basically, in that case it is not an "exception", but standard branch of execution.
>> you need to factor in the cost of what you're actually DOING inside of the exception handler
Again, the same issue. Exception is not supposed to be triggered that often so this cost will be significant.
- kstenerud 15y agoAnd yet we see this all the time, even in common libraries. I'd agree that it shouldn't happen, but the cold hard reality is that it does, and with shocking frequency. And when you're the poor sod who has to figure out why this legacy code you've inherited is so slow, it's common practice to look for bottlenecks such as these and find some way to tame the chaos.