From 076c412e8056187eac0d4cdbf1ecb9bccd6d346c Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 2 Jun 2006 23:56:19 +0000 Subject: [PATCH] Some more microoptimizations on the new definition list code. Now only about 4x slower than the old code instead of 6x. --- includes/Parser.php | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) 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: -- 2.20.1