2 Commits 8e99d0f6d4 ... 6b2eaf83c8

Author SHA1 Message Date
  Kajetan Johannes Hammerle 6b2eaf83c8 Use LTO for release 1 month ago
  Kajetan Johannes Hammerle ee952f7692 Simplified vector init 1 month ago
3 changed files with 12 additions and 18 deletions
  1. 3 3
      CMakeLists.txt
  2. 5 1
      include/core/data/ProbingHashMap.hpp
  3. 4 14
      include/core/math/Vector.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) {

+ 4 - 14
include/core/math/Vector.hpp

@@ -18,20 +18,10 @@ namespace Core {
         }
 
         template<typename OT, typename... Args>
-        Vector(OT a, Args&&... args) {
-            init<0>(a, args...);
-        }
-
-    private:
-        template<int I>
-        void init() {
-            static_assert(I == N, "vector parameters do not match its size");
-        }
-
-        template<int I, typename OT, typename... Args>
-        void init(OT a, Args&&... args) {
-            values[I] = static_cast<T>(a);
-            init<I + 1>(args...);
+        Vector(OT a, Args&&... args)
+            : values(static_cast<T>(a), static_cast<T>(args)...) {
+            static_assert(sizeof...(args) + 1 == N,
+                          "vector parameters do not match its size");
         }
 
     public: