This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Don't set variable within an 'if'
authorKarl Williamson <khw@cpan.org>
Wed, 31 May 2017 19:44:20 +0000 (13:44 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 1 Jun 2017 13:05:16 +0000 (07:05 -0600)
Sometimes it is convenient/and or necessary to do an assignment within a
clause of an 'if', but it adds a little cognitive load.  In this case,
it's entirely unnecessary.  This patch changes to do the assignment
before the 'if'.

regcomp.c

index 199fde9..b0a279e 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -13446,10 +13446,10 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
                  * this character again next time through, when it will be the
                  * only thing in its new node */
 
-                if ((next_is_quantifier = (   LIKELY(p < RExC_end)
-                                           && UNLIKELY(ISMULT2(p))))
-                    && LIKELY(len))
-               {
+                next_is_quantifier =    LIKELY(p < RExC_end)
+                                     && UNLIKELY(ISMULT2(p));
+
+                if (next_is_quantifier && LIKELY(len)) {
                     p = oldp;
                     goto loopdone;
                 }