From: Arran Cudbard-Bell Date: Wed, 18 Aug 2021 22:17:48 +0000 (-0500) Subject: Move array pop code to function and prevent it being inlined X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b0cc5f16a3208c2830598d30518c18fe8ac7f736;p=thirdparty%2Ffreeradius-server.git Move array pop code to function and prevent it being inlined --- diff --git a/src/lib/util/lst_tests.c b/src/lib/util/lst_tests.c index f7b2cf3f02d..8dd22d1763c 100644 --- a/src/lib/util/lst_tests.c +++ b/src/lib/util/lst_tests.c @@ -408,6 +408,24 @@ static void lst_iter(void) talloc_free(lst); } +static CC_HINT(noinline) lst_thing *array_pop(lst_thing **array, unsigned int count) +{ + lst_thing *low = NULL; + unsigned int idx = 0; + + for (unsigned int j = 0; j < count; j++) { + if (!array[j]) continue; + + if (!low || (lst_cmp(array[j], low) < 0)) { + idx = j; + low = array[j]; + } + } + if (low) array[idx] = NULL; + + return low; +} + /** Benchmarks for LSTs vs heaps when used as queues * */ @@ -510,19 +528,7 @@ static void queue_cmp(unsigned int count) start_pop = fr_time(); for (i = 0; i < count; i++) { - lst_thing *low = NULL; - unsigned int idx = 0; - - for (unsigned int j = 0; j < count; j++) { - if (!array[j]) continue; - - if (!low || (lst_cmp(array[j], low) < 0)) { - idx = j; - low = array[j]; - } - } - if (low) array[idx] = NULL; - + TEST_CHECK(array_pop(array, count) != NULL); if (i == 0) end_pop_first = fr_time(); } end_pop = fr_time();