From: Kevin Day Date: Thu, 27 Apr 2023 02:36:41 +0000 (-0500) Subject: Update: Slightly reduce recursion cost for private_fl_directory_do_recurse(). X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=ab94b211d07197134d47e6766f9850f514778593;p=fll Update: Slightly reduce recursion cost for private_fl_directory_do_recurse(). Make some constant structures static with the goal of reducing the cost of recursion. Using static should help avoid redeclaring these variables per execution. This should reduce memory for each recurse into the function. --- diff --git a/level_1/fl_directory/c/private-directory.c b/level_1/fl_directory/c/private-directory.c index 67b1a53..eb34e16 100644 --- a/level_1/fl_directory/c/private-directory.c +++ b/level_1/fl_directory/c/private-directory.c @@ -51,12 +51,22 @@ extern "C" { uint8_t j = 0; const f_array_length_t used_original = recurse->path.used; - const uint8_t flag_actions[] = { + static const uint8_t flag_actions[] = { f_directory_recurse_do_flag_before_e, 0, f_directory_recurse_do_flag_after_e, }; + static const uint16_t flags[] = { + f_directory_recurse_do_flag_block_e, + f_directory_recurse_do_flag_character_e, + f_directory_recurse_do_flag_regular_e, + f_directory_recurse_do_flag_link_e, + f_directory_recurse_do_flag_fifo_e, + f_directory_recurse_do_flag_socket_e, + f_directory_recurse_do_flag_unknown_e, + }; + { f_string_dynamics_t * const list[] = { &recurse->listing.block, @@ -68,16 +78,6 @@ extern "C" { &recurse->listing.unknown, }; - const uint16_t flags[] = { - f_directory_recurse_do_flag_block_e, - f_directory_recurse_do_flag_character_e, - f_directory_recurse_do_flag_regular_e, - f_directory_recurse_do_flag_link_e, - f_directory_recurse_do_flag_fifo_e, - f_directory_recurse_do_flag_socket_e, - f_directory_recurse_do_flag_unknown_e, - }; - for (uint8_t k = 0; k < 7; ++k) { for (i = 0; i < list[k]->used; ++i) {