This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_sv_vcatpvfn_flags: skip IN_LC(LC_NUMERIC)
authorDavid Mitchell <davem@iabyn.com>
Sat, 20 May 2017 15:01:26 +0000 (16:01 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 7 Jun 2017 08:11:03 +0000 (09:11 +0100)
In a couple of places it does

    if (PL_numeric_radix_sv && IN_LC(LC_NUMERIC)) { ... }

But PL_numeric_radix_sv is set to NULL unless we have a non-standard
radix point (i.e. not "."), and this can only happen when we're in the
scope of 'use locale'. So the IN_LC() should be a redundant (and
expensive) test. Replace it with an assert.

sv.c

diff --git a/sv.c b/sv.c
index 302315e..7c8271e 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -11667,9 +11667,10 @@ S_format_hexfp(pTHX_ char * const buf, const STRLEN bufsize, const char c,
 #ifndef USE_LOCALE_NUMERIC
             *p++ = '.';
 #else
 #ifndef USE_LOCALE_NUMERIC
             *p++ = '.';
 #else
-            if (PL_numeric_radix_sv && IN_LC(LC_NUMERIC)) {
+            if (PL_numeric_radix_sv) {
                 STRLEN n;
                 const char* r = SvPV(PL_numeric_radix_sv, n);
                 STRLEN n;
                 const char* r = SvPV(PL_numeric_radix_sv, n);
+                assert(IN_LC(LC_NUMERIC));
                 Copy(r, p, n, char);
                 p += n;
             }
                 Copy(r, p, n, char);
                 p += n;
             }
@@ -12760,7 +12761,8 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
                 lc_numeric_set = TRUE;
             }
 
                 lc_numeric_set = TRUE;
             }
 
-            if (PL_numeric_radix_sv && IN_LC(LC_NUMERIC)) {
+            if (PL_numeric_radix_sv) {
+                assert(IN_LC(LC_NUMERIC));
                 radix_len  = SvCUR(PL_numeric_radix_sv);
                 /* note that this will convert the output to utf8 even if
                  * if the radix point didn't get output */
                 radix_len  = SvCUR(PL_numeric_radix_sv);
                 /* note that this will convert the output to utf8 even if
                  * if the radix point didn't get output */