From 30d8a4a33db8e692e19f45d07edb267f0f72659e Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Thu, 16 Nov 2023 13:42:20 -0700 Subject: [PATCH] locale.c: Move some code When called with just a single item, we only need a single call to the populating function, so move this code ahead of the 2nd call. This also clarifies the comments. --- locale.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/locale.c b/locale.c index 044850ac9b86..0a23993587f5 100644 --- a/locale.c +++ b/locale.c @@ -5667,6 +5667,19 @@ S_my_localeconv(pTHX_ const int item) strings, integers ); +# ifndef HAS_SOME_LANGINFO /* Could be using this function to emulate + nl_langinfo() */ + + /* We are done when called with an individual item. There are no integer + * items to adjust, and it's best for the caller to determine if this + * string item is UTF-8 or not. This is because the locale's UTF-8ness is + * calculated below, and in some Configurations, that can lead to a + * recursive call to here, which could recurse infinitely. */ + if (item != 0) { + return hv; + } + +# endif /* The above call may have done all the hash fields, but not always, as * already explained. If we need a second call it is always for the @@ -5698,20 +5711,6 @@ S_my_localeconv(pTHX_ const int item) * cost which khw doesn't think is worth it */ -# ifndef HAS_SOME_LANGINFO - - /* We are done when called with an individual item. There are no integer - * items to adjust, and it's best for the caller to determine if this - * string item is UTF-8 or not. This is because the locale's UTF-8ness is - * calculated below, and in some Configurations, that can lead to a - * recursive call to here, which could recurse infinitely. */ - - if (item != 0) { - return hv; - } - -# endif - for (unsigned int i = 0; i < 2; i++) { /* Try both types of strings */ if (! strings[i]) { /* Skip if no strings of this type */ continue;