From 57fcbfa7eef9b70825a20226d93f531a65f195c2 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Fri, 27 Dec 2013 22:06:36 +0000 Subject: [PATCH] re_intuit_start(): refactor an if/else block change if (X) { do nothing } else if (Y) { Z } to if (!X && Y) { Z } --- regexec.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/regexec.c b/regexec.c index 8444816..9f0e2c6 100644 --- a/regexec.c +++ b/regexec.c @@ -685,15 +685,14 @@ Perl_re_intuit_start(pTHX_ if (!ml_anch) { /* we are only allowed to match at BOS or \G */ - if (prog->intflags & PREGf_ANCH_GPOS) { - /* in this case, we hope(!) that the caller has already - * set strpos to pos()-gofs, and will already have checked - * that this anchor position is legal - */ - ; - } - else if (!(prog->intflags & PREGf_IMPLICIT) /* not a real BOL */ - && (strpos != strbeg)) + /* trivially reject if there's a BOS anchor and we're not at BOS. + * In the case of \G, we hope(!) that the caller has already + * set strpos to pos()-gofs, and will already have checked + * that this anchor position is legal. So we can skip it here. + */ + if ( !(prog->intflags & PREGf_ANCH_GPOS) + && !(prog->intflags & PREGf_IMPLICIT) /* not a real BOL */ + && (strpos != strbeg)) { DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "Not at start...\n")); -- 2.7.4