gpt4 book ai didi

objective-c - 在 @try block 中调用函数是否会导致性能损失?

转载 作者:太空狗 更新时间:2023-10-30 03:48:34 25 4
gpt4 key购买 nike

与不使用 try block 调用 blabla 相比,这会导致性能下降吗?

-(void)bla{
@try{
[self blabla];
}
@catch (NSException *e) {
// Do nothing
}
}

最佳答案

来自 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.

因此 64 位 进程没有开销

关于objective-c - 在 @try block 中调用函数是否会导致性能损失?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22025482/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com