Does return statement optimize code running?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By crablord

So, sometimes when i use debug in godot i noticed that when the current function body ends without return or pass debugger in rare occasions continues to work on next empty rows after current function body. Debugger continues to do it until it finds new function body, after which it returns to whatever it was doing.
Of course, it doesnt wreck program logic or generate error but i was wondering if these extra debugger steps somehow add extra unnessary steps to program execution, so my question is: if i will add return statement at the end of the functions will it optimize the program?

You could try running diagnostics yourself to check this by comparing elapsed time values on similar functions. OS.get_time() is available everywhere.

DDoop | 2020-06-26 20:53

For accurate microbenchmarking, you’ll want to use OS.get_ticks_usec() which returns a value in microseconds instead of OS.get_time().

Calinou | 2020-06-29 12:44