* Use Preprocessor_Hash by default in compiled mode, it is faster
authorTim Starling <tstarling@users.mediawiki.org>
Tue, 31 May 2011 06:10:23 +0000 (06:10 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Tue, 31 May 2011 06:10:23 +0000 (06:10 +0000)
* Don't profile MagicWord::get(), it is very fast and the profiling overhead was excessive. Profile MagicWord::load() instead.

includes/MagicWord.php
includes/parser/Parser.php

index 99bd086..d157938 100644 (file)
@@ -197,13 +197,11 @@ class MagicWord {
         * @return MagicWord
         */
        static function &get( $id ) {
-               wfProfileIn( __METHOD__ );
                if ( !isset( self::$mObjects[$id] ) ) {
                        $mw = new MagicWord();
                        $mw->load( $id );
                        self::$mObjects[$id] = $mw;
                }
-               wfProfileOut( __METHOD__ );
                return self::$mObjects[$id];
        }
 
@@ -275,6 +273,7 @@ class MagicWord {
         */
        function load( $id ) {
                global $wgContLang;
+               wfProfileIn( __METHOD__ );
                $this->mId = $id;
                $wgContLang->getMagic( $this );
                if ( !$this->mSynonyms ) {
@@ -282,6 +281,7 @@ class MagicWord {
                        #throw new MWException( "Error: invalid magic word '$id'" );
                        wfDebugLog( 'exception', "Error: invalid magic word '$id'\n" );
                }
+               wfProfileOut( __METHOD__ );
        }
 
        /**
index 010da1f..c72c49a 100644 (file)
@@ -187,6 +187,9 @@ class Parser {
                        '[^][<>"\\x00-\\x20\\x7F]+) *([^\]\\x00-\\x08\\x0a-\\x1F]*?)\]/S';
                if ( isset( $conf['preprocessorClass'] ) ) {
                        $this->mPreprocessorClass = $conf['preprocessorClass'];
+               } elseif ( defined( 'MW_COMPILED' ) ) {
+                       # Preprocessor_Hash is much faster than Preprocessor_DOM in compiled mode
+                       $this->mPreprocessorClass = 'Preprocessor_Hash';
                } elseif ( extension_loaded( 'domxml' ) ) {
                        # PECL extension that conflicts with the core DOM extension (bug 13770)
                        wfDebug( "Warning: you have the obsolete domxml extension for PHP. Please remove it!\n" );
@@ -196,6 +199,7 @@ class Parser {
                } else {
                        $this->mPreprocessorClass = 'Preprocessor_Hash';
                }
+               wfDebug( __CLASS__ . ": using preprocessor: {$this->mPreprocessorClass}\n" );
        }
 
        /**