r14542 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r14541‎ | r14542 | r14543 >
Date:23:56, 2 June 2006
Author:brion
Status:old
Tags:
Comment:
Some more microoptimizations on the new definition list code. Now only about 4x slower than the old code instead of 6x.
Modified paths:
  • /trunk/phase3/includes/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -1991,7 +1991,8 @@
19921992 return false;
19931993 }
19941994
1995 - if( strpos( $str, '<' ) === false ) {
 1995+ $lt = strpos( $str, '<' );
 1996+ if( $lt === false || $lt > $pos ) {
19961997 // Easy; no tag nesting to worry about
19971998 $before = substr( $str, 0, $pos );
19981999 $after = substr( $str, $pos+1 );
@@ -2025,7 +2026,31 @@
20262027 // Embedded in a tag; don't break it.
20272028 break;
20282029 default:
2029 - // ignore
 2030+ // Skip ahead looking for something interesting
 2031+ $colon = strpos( $str, ':', $i );
 2032+ if( $colon === false ) {
 2033+ // Nothing else interesting
 2034+ wfProfileOut( $fname );
 2035+ return false;
 2036+ }
 2037+ $lt = strpos( $str, '<', $i );
 2038+ if( $stack === 0 ) {
 2039+ if( $lt === false || $colon < $lt ) {
 2040+ // We found it!
 2041+ $before = substr( $str, 0, $colon );
 2042+ $after = substr( $str, $colon + 1 );
 2043+ wfProfileOut( $fname );
 2044+ return $i;
 2045+ }
 2046+ }
 2047+ if( $lt === false ) {
 2048+ // Nothing else interesting to find; abort!
 2049+ // We're nested, but there's no close tags left. Abort!
 2050+ break 2;
 2051+ }
 2052+ // Skip ahead to next tag start
 2053+ $i = $lt;
 2054+ $state = MW_COLON_STATE_TAGSTART;
20302055 }
20312056 break;
20322057 case 1: // MW_COLON_STATE_TAG:

Status & tagging log