Would this cause a performance penalty, compared to calling blabla
without the try block?
-(void)bla{
@try{
[self blabla];
}
@catch (NSException *e) {
// Do nothing
}
}
from doc
Zero-Cost @try Blocks
64-bit processes that enter a zero-cost @try block incur no performance penalty. This is unlike the mechanism for 32-bit processes, which calls setjmp() and performs additional “bookkeeping”. However, throwing an exception is much more expensive in 64-bit executables. For best performance in 64-bit, you should throw exceptions only when absolutely necessary.
so no overhead for 64-bit processes
You might be interested in this blog here: LLVM PROJECT BLOG
That is, on Intel and since Okt. 2013, on ARM too, C++ exceptions are now "zero-cost".
The Objective-C exceptions are realized in terms of this implementation.
However, the need for an unwinder will disable a few optimization opportunities, so that code which requires to handle exceptions might be less optimal optimized that when no exceptions have to be handled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With