r89207 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89206‎ | r89207 | r89208 >
Date:06:10, 31 May 2011
Author:tstarling
Status:ok
Tags:
Comment:
* Use Preprocessor_Hash by default in compiled mode, it is faster
* Don't profile MagicWord::get(), it is very fast and the profiling overhead was excessive. Profile MagicWord::load() instead.
Modified paths:
  • /trunk/phase3/includes/MagicWord.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -187,6 +187,9 @@
188188 '[^][<>"\\x00-\\x20\\x7F]+) *([^\]\\x00-\\x08\\x0a-\\x1F]*?)\]/S';
189189 if ( isset( $conf['preprocessorClass'] ) ) {
190190 $this->mPreprocessorClass = $conf['preprocessorClass'];
 191+ } elseif ( defined( 'MW_COMPILED' ) ) {
 192+ # Preprocessor_Hash is much faster than Preprocessor_DOM in compiled mode
 193+ $this->mPreprocessorClass = 'Preprocessor_Hash';
191194 } elseif ( extension_loaded( 'domxml' ) ) {
192195 # PECL extension that conflicts with the core DOM extension (bug 13770)
193196 wfDebug( "Warning: you have the obsolete domxml extension for PHP. Please remove it!\n" );
@@ -196,6 +199,7 @@
197200 } else {
198201 $this->mPreprocessorClass = 'Preprocessor_Hash';
199202 }
 203+ wfDebug( __CLASS__ . ": using preprocessor: {$this->mPreprocessorClass}\n" );
200204 }
201205
202206 /**
Index: trunk/phase3/includes/MagicWord.php
@@ -197,13 +197,11 @@
198198 * @return MagicWord
199199 */
200200 static function &get( $id ) {
201 - wfProfileIn( __METHOD__ );
202201 if ( !isset( self::$mObjects[$id] ) ) {
203202 $mw = new MagicWord();
204203 $mw->load( $id );
205204 self::$mObjects[$id] = $mw;
206205 }
207 - wfProfileOut( __METHOD__ );
208206 return self::$mObjects[$id];
209207 }
210208
@@ -275,6 +273,7 @@
276274 */
277275 function load( $id ) {
278276 global $wgContLang;
 277+ wfProfileIn( __METHOD__ );
279278 $this->mId = $id;
280279 $wgContLang->getMagic( $this );
281280 if ( !$this->mSynonyms ) {
@@ -282,6 +281,7 @@
283282 #throw new MWException( "Error: invalid magic word '$id'" );
284283 wfDebugLog( 'exception', "Error: invalid magic word '$id'\n" );
285284 }
 285+ wfProfileOut( __METHOD__ );
286286 }
287287
288288 /**

Status & tagging log