diff options
author | Karl Williamson <public@khwilliamson.com> | 2013-06-20 12:28:12 -0600 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2013-07-07 13:29:44 -0600 |
commit | 01ec34b5d8c7075801bdb8ca8364cbe2027147dd (patch) | |
tree | 7730b5a5e2b26702a7b8da0301cd41c32370ce6f /util.c | |
parent | 28acfe03fc59abea4ef2451b134d560f411183ab (diff) | |
download | perl-01ec34b5d8c7075801bdb8ca8364cbe2027147dd.tar.gz |
util.c: Avoid unnecessary setlocale() calls
This code sets the locale to C around its work. This is unnecessary if
the locale is already C, and there is an existing global that indicates
this, that can be tested to avoid the sets.
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -4469,8 +4469,11 @@ Perl_upg_version(pTHX_ SV *ver, bool qv) SV *sv = SvNVX(ver) > 10e50 ? newSV(64) : 0; char *buf; #ifdef USE_LOCALE_NUMERIC - char *loc = savepv(setlocale(LC_NUMERIC, NULL)); - setlocale(LC_NUMERIC, "C"); + char *loc = NULL; + if (! PL_numeric_standard) { + loc = savepv(setlocale(LC_NUMERIC, NULL)); + setlocale(LC_NUMERIC, "C"); + } #endif if (sv) { Perl_sv_setpvf(aTHX_ sv, "%.9"NVff, SvNVX(ver)); @@ -4481,8 +4484,10 @@ Perl_upg_version(pTHX_ SV *ver, bool qv) buf = tbuf; } #ifdef USE_LOCALE_NUMERIC - setlocale(LC_NUMERIC, loc); - Safefree(loc); + if (loc) { + setlocale(LC_NUMERIC, loc); + Safefree(loc); + } #endif while (buf[len-1] == '0' && len > 0) len--; if ( buf[len-1] == '.' ) len--; /* eat the trailing decimal */ |