Browse Source

Use LTO for release

Kajetan Johannes Hammerle 1 month ago
parent
commit
6b2eaf83c8
2 changed files with 8 additions and 4 deletions
  1. 3 3
      CMakeLists.txt
  2. 5 1
      include/core/data/ProbingHashMap.hpp

+ 3 - 3
CMakeLists.txt

@@ -68,12 +68,12 @@ set(SRC_PERFORMANCE
 )
 
 if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
-    set(DEBUG_COMPILE "")
+    set(COMPILE_OPTIONS -flto)
     set(DEBUG_LINK "")
     set(LOG_LEVEL 2)
     set(ERROR_SIMULATOR "")
 else()
-    set(DEBUG_COMPILE --coverage)
+    set(COMPILE_OPTIONS --coverage)
     set(DEBUG_LINK gcov)
     set(LOG_LEVEL 4)
     set(ERROR_SIMULATOR "ERROR_SIMULATOR")
@@ -81,7 +81,7 @@ endif()
 
 add_library(core STATIC ${SRC})
 target_compile_options(core PUBLIC
-    ${DEBUG_COMPILE}
+    ${COMPILE_OPTIONS}
     -fdiagnostics-color=always
     -fno-exceptions
     -fno-rtti

+ 5 - 1
include/core/data/ProbingHashMap.hpp

@@ -164,7 +164,11 @@ namespace Core {
                 return Error::NONE;
             }
             ProbingHashMap<K, V> map;
-            i64 l = 1l << Math::roundUpLog2(Core::Math::max(minCapacity, 8l));
+            i64 shifts = Math::roundUpLog2(Core::Math::max(minCapacity, 8l));
+            if(shifts >= 48) {
+                return Error::CAPACITY_REACHED;
+            }
+            i64 l = 1l << shifts;
             CORE_RETURN_ERROR(map.keys.resize(l, emptyValue<K>()));
             map.values = reinterpret_cast<V*>(new AlignedType<V>[l]);
             if(map.values == nullptr) {