From a51abc4826fbfba76021cb10d83164ae5cff19f4 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sat, 9 Sep 2023 14:20:15 +0100 Subject: [PATCH] Compile some files with -O2 even in Debug mode These files are responsible for most of the runtime in Debug mode. Apply some optimizations to them even in Debug mode to get reasonable performance. Timedemo on my machine goes from 40s down to 25s. --- Source/CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 112b45692..3a2a415ed 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -169,6 +169,21 @@ set(libdevilutionx_SRCS utils/timer.cpp utils/utf8.cpp) +# These files are responsible for most of the runtime in Debug mode. +# Apply some optimizations to them even in Debug mode to get reasonable performance. +set(_optimize_in_debug_srcs + engine/render/clx_render.cpp + engine/render/dun_render.cpp + engine/render/text_render.cpp + utils/cel_to_clx.cpp + utils/cl2_to_clx.cpp + utils/pcx_to_clx.cpp) +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND CMAKE_BUILD_TYPE STREQUAL "Debug") + set_source_files_properties(${_optimize_in_debug_srcs} PROPERTIES COMPILE_OPTIONS "-O2") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set_source_files_properties(${_optimize_in_debug_srcs} PROPERTIES COMPILE_OPTIONS "$<$:/O2>") +endif() + if(SUPPORTS_MPQ) list(APPEND libdevilutionx_DEPS libmpq) list(APPEND libdevilutionx_SRCS