From c6e0ebbe5f38a82738d3f1868bd354c155a00a8e Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sat, 11 Nov 2023 11:58:26 -0700 Subject: [PATCH] locale.c: Simplify loop A slight restructuring saves some lines. --- locale.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/locale.c b/locale.c index ea374ff4717d..872b7ed9855b 100644 --- a/locale.c +++ b/locale.c @@ -5893,31 +5893,22 @@ S_populate_hash_from_localeconv(pTHX_ HV * hv, /* For each field for the given category ... */ const lconv_offset_t * category_strings = strings[i]; - while (1) { - const char * name = category_strings->name; - if (! name) { /* Quit at the end */ - break; - } + while (category_strings->name) { - /* we have set things up so that we know where in the returned + /* We have set things up so that we know where in the returned * structure, when viewed as a string, the corresponding value is. * */ const char *value = *((const char **)( lcbuf_as_string + category_strings->offset)); - - /* Set to get next string on next iteration */ - category_strings++; - - /* Skip if this platform doesn't have this field. */ - if (! value) { - continue; + if (value) { /* Copy to the hash */ + (void) hv_store(hv, + category_strings->name, + strlen(category_strings->name), + newSVpv(value, strlen(value)), + 0); } - /* Copy to the hash */ - (void) hv_store(hv, - name, strlen(name), - newSVpv(value, strlen(value)), - 0); + category_strings++; } /* Add any int fields to the HV* */