In my game, there are many things checked and often the indexes are out of bounds, and it’s usually ok if sometimes things are not drawn or checked for. Currently my code is easy enough to read, though when debugging, the game loses a frame or two because of the exceptions that are being logged. It works fine outside the VS though. When I tried to avoid exceptional situations using lots and lots of if statements, it greatly decreased code readability and removed the low fps loss. I wonder if it has any other effects.
In my game, there are many things checked and often the indexes are out
Share
Throwing exceptions is very resource intensive- it is vastly faster to use if/then statements or other “normal” flow control.
Exceptions are mainly expensive because generating the Exception instance requires a stack walk has to be performed to figure out where the exception was thrown (the stack trace). It also creates extra load for the Garbage Collector, and is considered very poor design to use exceptions outside of exceptional situations.