From: Brion Vibber Date: Fri, 2 Jun 2006 23:56:19 +0000 (+0000) Subject: Some more microoptimizations on the new definition list code. Now only about 4x slowe... X-Git-Tag: 1.31.0-rc.0~56923 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=076c412e8056187eac0d4cdbf1ecb9bccd6d346c;p=lhc%2Fweb%2Fwiklou.git Some more microoptimizations on the new definition list code. Now only about 4x slower than the old code instead of 6x. --- diff --git a/includes/Parser.php b/includes/Parser.php index 54b7e9b770..e580cc4d3e 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -1991,7 +1991,8 @@ class Parser return false; } - if( strpos( $str, '<' ) === false ) { + $lt = strpos( $str, '<' ); + if( $lt === false || $lt > $pos ) { // Easy; no tag nesting to worry about $before = substr( $str, 0, $pos ); $after = substr( $str, $pos+1 ); @@ -2025,7 +2026,31 @@ class Parser // Embedded in a tag; don't break it. break; default: - // ignore + // Skip ahead looking for something interesting + $colon = strpos( $str, ':', $i ); + if( $colon === false ) { + // Nothing else interesting + wfProfileOut( $fname ); + return false; + } + $lt = strpos( $str, '<', $i ); + if( $stack === 0 ) { + if( $lt === false || $colon < $lt ) { + // We found it! + $before = substr( $str, 0, $colon ); + $after = substr( $str, $colon + 1 ); + wfProfileOut( $fname ); + return $i; + } + } + if( $lt === false ) { + // Nothing else interesting to find; abort! + // We're nested, but there's no close tags left. Abort! + break 2; + } + // Skip ahead to next tag start + $i = $lt; + $state = MW_COLON_STATE_TAGSTART; } break; case 1: // MW_COLON_STATE_TAG: