4 ms·
The example int rc = fx (); if (rc != 0) handle_error (); can be simply converted into ASM ; call fx() and copy to acc JNZ handle_err
by narrowtux 8y ago
The example
int rc = fx ();
if (rc != 0)
handle_error ();
can be simply converted into ASM
; call fx() and copy to acc
JNZ handle_error
; rest of code
handle_error:
; code of handle_error()
whereas exceptions in C++ need to generate a lot more code than this
- mhh__ 8y agoThe C++ code can be compiled in such a way that it has no branching e.g. stack unwinding instead, which is slower in the case of an exception being thrown - However, exceptions shouldn't be used for non-exceptional circumstances.