Skip to content

Commit

Permalink
locale.c: Move some code
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
khwilliamson committed Nov 22, 2023
1 parent 0401b2a commit 080980e
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions locale.c
Expand Up @@ -5666,6 +5666,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
Expand Down Expand Up @@ -5697,20 +5710,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;
Expand Down

0 comments on commit 080980e

Please sign in to comment.