]> Kevux Git Server - fll/commitdiff
Update: memory simple delete and simple destroy loop tweaks
authorKevin Day <thekevinday@gmail.com>
Mon, 20 Apr 2020 04:44:28 +0000 (23:44 -0500)
committerKevin Day <thekevinday@gmail.com>
Mon, 20 Apr 2020 04:44:58 +0000 (23:44 -0500)
Move the conditional outside of the loop for theoretical performance improvements.

level_0/f_memory/c/memory.h

index be48631b23fcece17e91ed785e38f69c22678de8..c02346169e835e417d879f1edd790d29f2743d13 100644 (file)
@@ -397,10 +397,10 @@ extern "C" {
     while (structures.used > 0) { \
       structures.used--; \
       f_macro_memory_structure_delete_simple(structures.array[structures.used], type); \
-      if (structures.used == 0) { \
-        if (f_memory_delete((void **) & structures.array, sizeof(type), structures.size)) { \
-          structures.size = 0; \
-        } \
+    } \
+    if (structures.used == 0) { \
+      if (f_memory_delete((void **) & structures.array, sizeof(type), structures.size)) { \
+        structures.size = 0; \
       } \
     }
 #endif // _di_f_macro_memory_structures_delete_simple_
@@ -417,10 +417,10 @@ extern "C" {
     while (structures.used > 0) { \
       structures.used--; \
       f_macro_memory_structure_destroy_simple(structures.array[structures.used], type); \
-      if (structures.used == 0) { \
-        if (f_memory_destroy((void **) & structures.array, sizeof(type), structures.size)) { \
-          structures.size = 0; \
-        } \
+    } \
+    if (structures.used == 0) { \
+      if (f_memory_destroy((void **) & structures.array, sizeof(type), structures.size)) { \
+        structures.size = 0; \
       } \
     }
 #endif // _di_f_macro_memory_structures_destroy_simple_