From b66b72b115c9ed6102061c452fb651dd3ea316d8 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Tue, 29 Oct 2024 18:37:18 +0100 Subject: [PATCH] get_alloc_string: compare only enum Instead of possibly checking for cling_by_tags string twice, just compare resulting alloc number from search loop. --- lib/display/display.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/display/display.c b/lib/display/display.c index b79c77227..15a7f3d1b 100644 --- a/lib/display/display.c +++ b/lib/display/display.c @@ -65,14 +65,16 @@ const char *get_alloc_string(alloc_policy_t alloc) alloc_policy_t get_alloc_from_string(const char *str) { int i; - - /* cling_by_tags is part of cling */ - if (!strcmp("cling_by_tags", str)) - return ALLOC_CLING; + alloc_policy_t alloc; for (i = 0; i < _num_policies; i++) - if (!strcmp(_policies[i].str, str)) - return _policies[i].alloc; + if (!strcmp(_policies[i].str, str)) { + alloc = _policies[i].alloc; + /* cling_by_tags is part of cling */ + if (alloc == ALLOC_CLING_BY_TAGS) + alloc = ALLOC_CLING; + return alloc; + } /* Special case for old metadata */ if (!strcmp("next free", str))