This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Simplify a few lines of code
authorKarl Williamson <khw@cpan.org>
Sun, 14 Feb 2016 00:21:28 +0000 (17:21 -0700)
committerKarl Williamson <khw@cpan.org>
Fri, 19 Feb 2016 03:26:50 +0000 (20:26 -0700)
This code had been written before the isMNEMONIC_CNTRL() macro was
created.  Using the macro simplifies things a little.

regcomp.c

index d28318f..5316887 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -19176,14 +19176,11 @@ S_put_code_point(pTHX_ SV *sv, UV c)
            sv_catpvs(sv, "\\");
        sv_catpvn(sv, &string, 1);
     }
+    else if (isMNEMONIC_CNTRL(c)) {
+        Perl_sv_catpvf(aTHX_ sv, "%s", cntrl_to_mnemonic((U8) c));
+    }
     else {
-        const char * const mnemonic = cntrl_to_mnemonic((char) c);
-        if (mnemonic) {
-            Perl_sv_catpvf(aTHX_ sv, "%s", mnemonic);
-        }
-        else {
-            Perl_sv_catpvf(aTHX_ sv, "\\x%02X", (U8) c);
-        }
+        Perl_sv_catpvf(aTHX_ sv, "\\x%02X", (U8) c);
     }
 }