From 95ab2826ecdf4db25bf19d9348ff334f9304a201 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 29 Dec 2014 23:53:00 +0100 Subject: [PATCH] avoid running over the array of locales in order.c when re-creating locales for tests. --- src/kernel/order.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/kernel/order.c b/src/kernel/order.c index d98853127..98d7919d6 100644 --- a/src/kernel/order.c +++ b/src/kernel/order.c @@ -40,8 +40,7 @@ typedef struct locale_data { const struct locale *lang; } locale_data; -static struct locale_data *locale_array[16]; -static int nlocales = 0; +static struct locale_data *locale_array[MAXLOCALES]; typedef struct order_data { const char *_str; @@ -272,15 +271,10 @@ static order *create_order_i(keyword_t kwd, const char *sptr, int persistent, } } - for (lindex = 0; lindex != nlocales; ++lindex) { - if (locale_array[lindex]->lang == lang) - break; - } - if (lindex == nlocales) { - locale_array[nlocales] = (locale_data *)calloc(1, sizeof(locale_data)); - locale_array[nlocales]->lang = lang; - ++nlocales; - } + lindex = locale_index(lang); + assert(lindex < MAXLOCALES); + locale_array[lindex] = (locale_data *)calloc(1, sizeof(locale_data)); + locale_array[lindex]->lang = lang; ord = (order *)malloc(sizeof(order)); ord->_persistent = persistent;