|
|
|
|
|
by Kamq
750 days ago
|
|
> In the happy case (no exception) how can the first version be harder to optimize than the second one? If your runtime has to do extra work to support stack-unwinding, it could easily be slower. You're doing work in the happy path in that case just in case the sad path happens. My guess is adding function metadata to some sort of datastructure (linked list?) so that it can figure out whats happening when it long jumps to the handler. I'd bet that allocation has at least one conditional in it. The alternative would be putting the metadata on the stack, letting the function complete normally, and then check a flag to see which path you're on (same overhead). To be clear, I have no idea how various runtimes implement this, just that the extra magic could easily have the same, or more, overhead than a conditional check. |
|