From 98547a4378a2cbaa528c8b5210e68cc02cde2441 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 31 Mar 2022 23:48:29 -0500 Subject: [PATCH] Update: Remove inefficient and pointless size increase. This must have been by accident or by habit. The (range->stop - range->start) for these shouldn't be happening. These checks are solely for ensuring there is enough room after what is already allocated. The behavior is actually potentially doubling its size. Only increase size by the required amount. There are likely other such problems that need to be fixed across this project. I will likely not get to these by the 0.6.0 stable release and will have to address them following that as I find them. --- level_1/fl_fss/c/fss/basic.c | 2 +- level_1/fl_fss/c/fss/basic_list.c | 4 ++-- level_1/fl_fss/c/fss/embedded_list.c | 4 ++-- level_1/fl_fss/c/fss/extended_list.c | 4 ++-- level_1/fl_fss/c/private-fss.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/level_1/fl_fss/c/fss/basic.c b/level_1/fl_fss/c/fss/basic.c index d47e02e..b547f24 100644 --- a/level_1/fl_fss/c/fss/basic.c +++ b/level_1/fl_fss/c/fss/basic.c @@ -181,7 +181,7 @@ extern "C" { } // Ensure that there is room for the potential terminating newline. - status = f_string_dynamic_increase_by((range->stop - range->start) + 2, destination); + status = f_string_dynamic_increase_by(2, destination); if (F_status_is_error(status)) return status; const f_array_length_t destination_used = destination->used; diff --git a/level_1/fl_fss/c/fss/basic_list.c b/level_1/fl_fss/c/fss/basic_list.c index 28ded15..3b99a4d 100644 --- a/level_1/fl_fss/c/fss/basic_list.c +++ b/level_1/fl_fss/c/fss/basic_list.c @@ -585,7 +585,7 @@ extern "C" { } // Ensure that there is room for a slash delimit, the object open character, and the end of line character. - status = f_string_dynamic_increase_by((range->stop - range->start) + 4, destination); + status = f_string_dynamic_increase_by(4, destination); if (F_status_is_error(status)) return status; const f_array_length_t used_start = destination->used; @@ -799,7 +799,7 @@ extern "C" { } // Ensure that there is room for a slash delimit and possibly the end of content character. - status = f_string_dynamic_increase_by((range->stop - range->start) + 3, destination); + status = f_string_dynamic_increase_by(3, destination); if (F_status_is_error(status)) return status; const f_array_length_t used_start = destination->used; diff --git a/level_1/fl_fss/c/fss/embedded_list.c b/level_1/fl_fss/c/fss/embedded_list.c index c8fe8d2..4d25f49 100644 --- a/level_1/fl_fss/c/fss/embedded_list.c +++ b/level_1/fl_fss/c/fss/embedded_list.c @@ -1001,7 +1001,7 @@ extern "C" { } // Ensure that there is room for a slash delimit, the object open character, and the end of line character. - status = f_string_dynamic_increase_by((range->stop - range->start) + 4, destination); + status = f_string_dynamic_increase_by(4, destination); if (F_status_is_error(status)) return status; const f_array_length_t used_start = destination->used; @@ -1237,7 +1237,7 @@ extern "C" { } // Ensure that there is room for a slash delimit and possibly the end of content characters. - status = f_string_dynamic_increase_by((range->stop - range->start) + 4, destination); + status = f_string_dynamic_increase_by(4, destination); if (F_status_is_error(status)) return status; const f_array_length_t used_start = destination->used; diff --git a/level_1/fl_fss/c/fss/extended_list.c b/level_1/fl_fss/c/fss/extended_list.c index 33d8b34..7c05ff1 100644 --- a/level_1/fl_fss/c/fss/extended_list.c +++ b/level_1/fl_fss/c/fss/extended_list.c @@ -548,7 +548,7 @@ extern "C" { } // Ensure that there is room for a slash delimit, the object open character, and the end of line character. - status = f_string_dynamic_increase_by((range->stop - range->start) + 4, destination); + status = f_string_dynamic_increase_by(4, destination); if (F_status_is_error(status)) return status; const f_array_length_t used_start = destination->used; @@ -784,7 +784,7 @@ extern "C" { } // Ensure that there is room for a slash delimit and possibly the end of content characters. - status = f_string_dynamic_increase_by((range->stop - range->start) + 4, destination); + status = f_string_dynamic_increase_by(4, destination); if (F_status_is_error(status)) return status; const f_array_length_t used_start = destination->used; diff --git a/level_1/fl_fss/c/private-fss.c b/level_1/fl_fss/c/private-fss.c index cd90c51..2cfcd44 100644 --- a/level_1/fl_fss/c/private-fss.c +++ b/level_1/fl_fss/c/private-fss.c @@ -856,7 +856,7 @@ extern "C" { } // Ensure that there is room for the potential start and stop quotes, a potential delimit at start, and the potential object open character. - status = f_string_dynamic_increase_by((range->stop - range->start) + 5, destination); + status = f_string_dynamic_increase_by(5, destination); if (F_status_is_error(status)) return status; const f_array_length_t input_start = range->start; -- 1.8.3.1