ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl5-porters
perl5-porters
[PATCH 5.7.0] Minor optimization in re_intuit_start
by Ilya Zakharevich other posts by this author
Sep 28 2000 9:55PM messages near this date
SuSE's gcc-2.95.2 and //depot/perl | Memory allocation in 5.6
This patch moves a quite important and cheap check from inside a
branch which is not important to this check.

Enjoy,
Ilya

--- ./regexec.c~	Fri Aug 18 16:31:18 2000
+++ ./regexec.c	Thu Sep 28 18:52:39 2000
@@ -357,17 +357,18 @@ Perl_re_intuit_start(pTHX_ regexp *prog,
 		     || ( (prog-> reganch & ROPT_ANCH_BOL)
 			  && !PL_multiline ) );	/* Check after \n? */
 
-	if ((prog-> check_offset_min == prog->check_offset_max) && !ml_anch) {
+	if (!ml_anch) {
+	  if ( !(prog-> reganch & ROPT_ANCH_GPOS) /* Checked by the caller */
+	       /* SvCUR is not set on references: SvRV and SvPVX overlap */
+	       && sv && !SvROK(sv)
+	       && (strpos + SvCUR(sv) != strend)) {
+	      DEBUG_r(PerlIO_printf(Perl_debug_log, "Not at start...\n"));
+	      goto fail;
+	  }
+	  if (prog-> check_offset_min == prog->check_offset_max) {
 	    /* Substring at constant offset from beg-of-str... */
 	    I32 slen;
 
-	    if ( !(prog-> reganch & ROPT_ANCH_GPOS) /* Checked by the caller */
-		 /* SvCUR is not set on references: SvRV and SvPVX overlap */
-		 && sv && !SvROK(sv)
-		 && (strpos + SvCUR(sv) != strend)) {
-		DEBUG_r(PerlIO_printf(Perl_debug_log, "Not at start...\n"));
-		goto fail;
-	    }
 	    PL_regeol = strend;			/* Used in HOP() */
 	    s = HOPc(strpos, prog-> check_offset_min);
 	    if (SvTAIL(check)) {
@@ -393,6 +394,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog,
 			 && memNE(SvPVX(check), s, slen)))
 		goto report_neq;
 	    goto success_at_start;
+	  }
 	}
 	/* Match is anchored, but substr is not anchored wrt beg-of-str. */
 	s = strpos;

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved