In what ways do C++ exceptions slow down code when there are no exceptions thown?

后端 未结 6 1872
终归单人心
终归单人心 2020-11-27 14:19

I have read that there is some overhead to using C++ exceptions for exception handling as opposed to, say, checking return values. I\'m only talking about overhead that is i

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 14:54

    Only try/catch and try/except block take a few instructions to set up. The overhead should generally be negligible in every case except the tighest loops. But you wouldn't normally use try/catch/except in an inner loop anyway.

    I would advise not to worry about this, and use a profiler instead to optimize your code where needed.

提交回复
热议问题