From 0bb6ed1f82a1c3509452270a4980557e8d7a0346 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 19 Apr 2020 23:44:28 -0500 Subject: [PATCH] Update: memory simple delete and simple destroy loop tweaks Move the conditional outside of the loop for theoretical performance improvements. --- level_0/f_memory/c/memory.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/level_0/f_memory/c/memory.h b/level_0/f_memory/c/memory.h index be48631..c023461 100644 --- a/level_0/f_memory/c/memory.h +++ b/level_0/f_memory/c/memory.h @@ -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_ -- 1.8.3.1