From: Aaron Schulz Date: Wed, 20 Aug 2008 01:03:01 +0000 (+0000) Subject: Remark static functions for performance. Same 15 test failures as before this change. X-Git-Tag: 1.31.0-rc.0~45783 X-Git-Url: https://git.cyclocoop.org/admin/?a=commitdiff_plain;h=b16705dcb12b0354ff0d09d3a831a03b05dbee24;p=lhc%2Fweb%2Fwiklou.git Remark static functions for performance. Same 15 test failures as before this change. --- diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 5f97184772..0e94c99a58 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -512,7 +512,7 @@ class Parser * @public * @static */ - function extractTagsAndParams($elements, $text, &$matches, $uniq_prefix = ''){ + static function extractTagsAndParams($elements, $text, &$matches, $uniq_prefix = ''){ static $n = 1; $stripped = ''; $matches = array(); @@ -652,7 +652,7 @@ class Parser * @public * @static */ - function tidy( $text ) { + static function tidy( $text ) { global $wgTidyInternal; $wrappedtext = ''. @@ -675,7 +675,7 @@ class Parser * @private * @static */ - function externalTidy( $text ) { + static function externalTidy( $text ) { global $wgTidyConf, $wgTidyBin, $wgTidyOpts; $fname = 'Parser::externalTidy'; wfProfileIn( $fname ); @@ -727,7 +727,7 @@ class Parser * @private * @static */ - function internalTidy( $text ) { + static function internalTidy( $text ) { global $wgTidyConf, $IP, $wgDebugTidy; $fname = 'Parser::internalTidy'; wfProfileIn( $fname ); @@ -974,12 +974,12 @@ class Parser $text = preg_replace( '/(^|\n)-----*/', '\\1
', $text ); $text = $this->doDoubleUnderscore( $text ); - $text = $this->doHeadings( $text ); + $text = self::doHeadings( $text ); if($this->mOptions->getUseDynamicDates()) { $df = DateFormatter::getInstance(); $text = $df->reformat( $this->mOptions->getDateFormat(), $text ); } - $text = $this->doAllQuotes( $text ); + $text = self::doAllQuotes( $text ); $text = $this->replaceInternalLinks( $text ); $text = $this->replaceExternalLinks( $text ); @@ -1059,7 +1059,7 @@ class Parser * * @private */ - function doHeadings( $text ) { + static function doHeadings( $text ) { $fname = 'Parser::doHeadings'; wfProfileIn( $fname ); for ( $i = 6; $i >= 1; --$i ) { @@ -1076,13 +1076,13 @@ class Parser * @private * @return string the altered text */ - function doAllQuotes( $text ) { + static function doAllQuotes( $text ) { $fname = 'Parser::doAllQuotes'; wfProfileIn( $fname ); $outtext = ''; $lines = explode( "\n", $text ); foreach ( $lines as $line ) { - $outtext .= $this->doQuotes ( $line ) . "\n"; + $outtext .= self::doQuotes( $line ) . "\n"; } $outtext = substr($outtext, 0,-1); wfProfileOut( $fname ); @@ -1092,7 +1092,7 @@ class Parser /** * Helper function for doAllQuotes() */ - public function doQuotes( $text ) { + public static function doQuotes( $text ) { $arr = preg_split( "/(''+)/", $text, -1, PREG_SPLIT_DELIM_CAPTURE ); if ( count( $arr ) == 1 ) return $text; @@ -1969,7 +1969,7 @@ class Parser # getCommon() returns the length of the longest common substring # of both arguments, starting at the beginning of both. # - /* private */ function getCommon( $st1, $st2 ) { + /* private */ static function getCommon( $st1, $st2 ) { $fl = strlen( $st1 ); $shorter = strlen( $st2 ); if ( $fl < $shorter ) { $shorter = $fl; } @@ -2085,14 +2085,14 @@ class Parser # So we check for : in the remainder text to split up the # title and definition, without b0rking links. $term = $t2 = ''; - if ($this->findColonNoLinks($t, $term, $t2) !== false) { + if ( self::findColonNoLinks($t, $term, $t2) !== false ) { $t = $t2; $output .= $term . $this->nextItem( ':' ); } } } elseif( $prefixLength || $lastPrefixLength ) { # Either open or close a level... - $commonPrefixLength = $this->getCommon( $pref, $lastPrefix ); + $commonPrefixLength = self::getCommon( $pref, $lastPrefix ); $paragraphStack = false; while( $commonPrefixLength < $lastPrefixLength ) { @@ -2108,7 +2108,7 @@ class Parser if ( ';' == $char ) { # FIXME: This is dupe of code above - if ($this->findColonNoLinks($t, $term, $t2) !== false) { + if ( self::findColonNoLinks($t, $term, $t2) !== false ) { $t = $t2; $output .= $term . $this->nextItem( ':' ); } @@ -2205,7 +2205,7 @@ class Parser * @param string &$after set to everything after the ':' * return string the position of the ':', or false if none found */ - function findColonNoLinks($str, &$before, &$after) { + static function findColonNoLinks($str, &$before, &$after) { $fname = 'Parser::findColonNoLinks'; wfProfileIn( $fname ); @@ -3155,10 +3155,10 @@ class Parser if (strlen($url) > 255) return wfMsg('scarytranscludetoolong'); - return $this->fetchScaryTemplateMaybeFromCache($url); + return self::fetchScaryTemplateMaybeFromCache($url); } - function fetchScaryTemplateMaybeFromCache($url) { + static function fetchScaryTemplateMaybeFromCache($url) { global $wgTranscludeCacheExpiry; $dbr = wfGetDB(DB_SLAVE); $obj = $dbr->selectRow('transcache', array('tc_time', 'tc_contents'), @@ -3789,7 +3789,7 @@ class Parser wfDebug( __METHOD__ . ": $username has overlong signature.\n" ); } elseif( $user->getBoolOption( 'fancysig' ) !== false ) { # Sig. might contain markup; validate this - if( $this->validateSig( $nickname ) !== false ) { + if( self::validateSig( $nickname ) !== false ) { # Validated; clean up (if needed) and return it return $this->cleanSig( $nickname, true ); } else { @@ -3800,7 +3800,7 @@ class Parser } // Make sure nickname doesnt get a sig in a sig - $nickname = $this->cleanSigInSig( $nickname ); + $nickname = self::cleanSigInSig( $nickname ); # If we're still here, make it a link to the user page $userText = wfEscapeWikiText( $username ); @@ -3818,7 +3818,7 @@ class Parser * @param string $text * @return mixed An expanded string, or false if invalid. */ - function validateSig( $text ) { + static function validateSig( $text ) { return( wfIsWellFormedXmlFragment( $text ) ? $text : false ); } @@ -3853,7 +3853,7 @@ class Parser $substText = '{{' . $substWord->getSynonym( 0 ); $text = preg_replace( $substRegex, $substText, $text ); - $text = $this->cleanSigInSig( $text ); + $text = self::cleanSigInSig( $text ); $dom = $this->preprocessToDom( $text ); $frame = $this->getPreprocessor()->newFrame(); $text = $frame->expand( $dom ); @@ -3870,7 +3870,7 @@ class Parser * @param string $text * @return string Signature text with /~{3,5}/ removed */ - function cleanSigInSig( $text ) { + static function cleanSigInSig( $text ) { $text = preg_replace( '/~{3,5}/', '', $text ); return $text; }