Skip to content

Commit

Permalink
locale.c: Avoid unnecessary work around localeconv()
Browse files Browse the repository at this point in the history
There are now two different functions that return the values for
localeconv().  One is for when the locale is "C"; the other for
everything else.  The C one returns values that don't need adjusting, so
skip that for this case.
  • Loading branch information
khwilliamson committed Nov 20, 2023
1 parent 9557ea4 commit 1889995
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions locale.c
Expand Up @@ -5724,23 +5724,29 @@ S_my_localeconv(pTHX_ const int item)

for (unsigned int i = 0; i < 2; i++) { /* Try both types of strings */

/* The return from this function is already adjusted */
if (populate[i] == S_populate_hash_from_C_localeconv) {
continue;
}

/* Examine each string */
for (const lconv_offset_t *strp = strings[i]; strp->name; strp++) {
const char * name = strp->name;

/* 'value' will contain the string that may need to be marked as
* UTF-8 */
SV ** value = hv_fetch(hv, name, strlen(name), true);
if (! value || ! SvPOK(*value)) {
if (value == NULL) {
continue;
}

/* Determine if the string should be marked as UTF-8. */
if (UTF8NESS_YES == (get_locale_string_utf8ness_i(SvPVX(*value),
LOCALE_UTF8NESS_UNKNOWN,
locales[i],
LC_ALL_INDEX_ /* OOB */)))
{
if ( UTF8NESS_YES
== (get_locale_string_utf8ness_i(SvPVX(*value),
LOCALE_UTF8NESS_UNKNOWN,
locales[i],
LC_ALL_INDEX_ /* OOBounds */
))) {
SvUTF8_on(*value);
}
}
Expand Down

0 comments on commit 1889995

Please sign in to comment.