Permalink
Browse files

locale.c: Avoid some more locale changes

In a few places here we can test if we are already in the locale we want
to be in, and not switch unnecessarily if so.
  • Loading branch information...
khwilliamson committed Jan 2, 2018
1 parent e6c7263 commit 250a1aa55a6e9c96a23c6c0820ce49baca3223bd
Showing with 12 additions and 6 deletions.
  1. +12 −6 locale.c
View
@@ -1129,7 +1129,8 @@ Perl_setlocale(int category, const char * locale)
# ifdef LC_ALL
else if (category == LC_ALL) {
else if (category == LC_ALL && ! PL_numeric_underlying) {
SET_NUMERIC_UNDERLYING();
}
@@ -1424,7 +1425,9 @@ S_my_nl_langinfo(const int item, bool toggle)
LOCALE_LOCK;
if (toggle) {
if (item == PERL_RADIXCHAR || item == PERL_THOUSEP) {
if ( ! PL_numeric_underlying
&& (item == PERL_RADIXCHAR || item == PERL_THOUSEP))
{
do_setlocale_c(LC_NUMERIC, PL_numeric_name);
}
else {
@@ -1450,9 +1453,7 @@ S_my_nl_langinfo(const int item, bool toggle)
do_free = TRUE;
}
if ( toggle
&& (item == PERL_RADIXCHAR || item == PERL_THOUSEP))
{
if (toggle) {
cur = newlocale(LC_NUMERIC_MASK, PL_numeric_name, cur);
do_free = TRUE;
}
@@ -1556,7 +1557,12 @@ S_my_nl_langinfo(const int item, bool toggle)
LOCALE_LOCK;
if (toggle) {
do_setlocale_c(LC_NUMERIC, PL_numeric_name);
if (! PL_numeric_underlying) {
do_setlocale_c(LC_NUMERIC, PL_numeric_name);
}
else {
toggle = FALSE;
}
}
lc = localeconv();

0 comments on commit 250a1aa

Please sign in to comment.