This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Swap 'if' branches for readability
authorKarl Williamson <khw@cpan.org>
Wed, 7 Nov 2018 00:41:18 +0000 (17:41 -0700)
committerKarl Williamson <khw@cpan.org>
Fri, 16 Nov 2018 17:48:18 +0000 (10:48 -0700)
It's easier to understand if the simplest case is first in the code.

regcomp.c

index 7f6bbc8..758bc33 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -14101,14 +14101,14 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
                 if (! FOLD) {  /* The simple case, just append the literal */
 
                       not_fold_common:
-                        if (UTF && ! UVCHR_IS_INVARIANT(ender)) {
+                        if (UVCHR_IS_INVARIANT(ender) || ! UTF) {
+                            *(s++) = (char) ender;
+                        }
+                        else {
                             U8 * new_s = uvchr_to_utf8((U8*)s, ender);
                             added_len = (char *) new_s - s;
                             s = (char *) new_s;
                         }
-                        else {
-                            *(s++) = (char) ender;
-                        }
                 }
                 else if (LOC && is_PROBLEMATIC_LOCALE_FOLD_cp(ender)) {