3 ms·
Also, exceptions are faster. There is a lot of comparisons and branching going on, when the program always checks return codes. Assuming zero-cost exceptions,
by qznc 13y ago
Also, exceptions are faster.
There is a lot of comparisons and branching going on, when the program always checks return codes. Assuming zero-cost exceptions, there is only overhead in the failure case.
- waps 13y agoI also find it very disingenious of the pro-exceptions post to claim that these mazes of ifs are easy to navigate. In his example that is sort-of true. When you're using actual real data to make the comparison it's easy to introduce very hard to trace bugs in them. Once I had two things to check, one being time, and as you know that means 8 cases. You have to pick one to check first, and I picked the non-time based check to check first. That means that I suddenly didn't check all cases anymore : if (currentTime() < topBound) { if (some other condition) { if (currentTime() > lowerBound) { // at this point you of course do NOT know for sure that currentTime < topBound. Whoops. (these look like they can be trivially merged. That's true if you look at just these lines, it becomes false if you look at the full set of conditions).