1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Optimize-out some debug and/or non-tools methods

Collisions and nav debug are conditionally compiled depending on DEBUG_ENABLED
is_editor_hint() and is_node_being_edited() are compiled only with TOOLS_ENABLED
Every affected method is implemented in the header in case its macro is not present (the getters just returning false and the setters having an empty body) so the compiler can inline and finally no-op-out them as likely as possible.
is_node_being_edited() already showed a similar optimization effort and has been adapted to this change.
Furthermore, and as a consequence, -debugcol and -debugnav will not work on non-debug (strict release) builds.
This can bring a little bit of runtime performance on release and non-tooled builds (less code, so less cycles to spend and maybe more cache friendly).
This commit is contained in:
Pedro J. Estébanez
2017-04-07 16:17:16 +02:00
parent 65f8210e50
commit 665bf52948
3 changed files with 36 additions and 5 deletions

View File

@@ -94,8 +94,10 @@ static bool init_maximized = false;
static bool init_windowed = false;
static bool init_fullscreen = false;
static bool init_use_custom_pos = false;
#ifdef DEBUG_ENABLED
static bool debug_collisions = false;
static bool debug_navigation = false;
#endif
static int frame_delay = 0;
static Vector2 init_custom_pos;
static int video_driver_idx = -1;
@@ -498,10 +500,12 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "-debug" || I->get() == "-d") {
debug_mode = "local";
#ifdef DEBUG_ENABLED
} else if (I->get() == "-debugcol" || I->get() == "-dc") {
debug_collisions = true;
} else if (I->get() == "-debugnav" || I->get() == "-dn") {
debug_navigation = true;
#endif
} else if (I->get() == "-editor_scene") {
if (I->next()) {
@@ -1194,12 +1198,15 @@ bool Main::start() {
SceneTree *sml = main_loop->cast_to<SceneTree>();
#ifdef DEBUG_ENABLED
if (debug_collisions) {
sml->set_debug_collisions_hint(true);
}
if (debug_navigation) {
sml->set_debug_navigation_hint(true);
}
#endif
#ifdef TOOLS_ENABLED
EditorNode *editor_node = NULL;