r6590 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r6589‎ | r6590 | r6591 >
Date:05:46, 9 December 2004
Author:vibber
Status:old
Tags:
Comment:
* Defer message cache initialization, shaving a few ms off file cache hits
Modified paths:
  • /branches/REL1_4/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_4/phase3/includes/MessageCache.php (modified) (history)
  • /branches/REL1_4/phase3/includes/Parser.php (modified) (history)
  • /branches/REL1_4/phase3/includes/Setup.php (modified) (history)
  • /branches/REL1_4/phase3/includes/Skin.php (modified) (history)
  • /branches/REL1_4/phase3/index.php (modified) (history)
  • /branches/REL1_4/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: branches/REL1_4/phase3/index.php
@@ -31,10 +31,6 @@
3232 $action = $wgRequest->getVal( "action", "view" );
3333 $title = $wgRequest->getVal( "title" );
3434
35 -# Placeholders in case of DB error
36 -$wgTitle = Title::newFromText( wfMsgForContent( "badtitle" ) );
37 -$wgArticle = new Article($wgTitle);
38 -
3935 $action = strtolower( trim( $action ) );
4036 if ($wgRequest->getVal( "printable" ) == "yes") {
4137 $wgOut->setPrintable();
Index: branches/REL1_4/phase3/includes/MessageCache.php
@@ -23,6 +23,7 @@
2424 var $mMemcKey, $mKeys, $mParserOptions, $mParser;
2525 var $mExtensionMessages;
2626 var $mInitialised = false;
 27+ var $mDeferred = true;
2728
2829 function initialise( &$memCached, $useDB, $expiry, $memcPrefix) {
2930 $fname = 'MessageCache::initialise';
@@ -44,7 +45,12 @@
4546 $this->mParser = new Parser;
4647 wfProfileOut( $fname.'-parser' );
4748
48 - $this->load();
 49+ # When we first get asked for a message,
 50+ # then we'll fill up the cache. If we
 51+ # can return a cache hit, this saves
 52+ # some extra milliseconds
 53+ $this->mDeferred = true;
 54+
4955 wfProfileOut( $fname );
5056 }
5157
@@ -113,6 +119,7 @@
114120 }
115121 }
116122 wfProfileOut( $fname );
 123+ $this->mDeferred = false;
117124 return $success;
118125 }
119126
@@ -221,6 +228,10 @@
222229 if( !$this->mInitialised ) {
223230 return "<$key>";
224231 }
 232+ # If cache initialization was deferred, start it now.
 233+ if( $this->mDeferred ) {
 234+ $this->load();
 235+ }
225236
226237 $message = false;
227238 if( !$this->mDisable && $useDB ) {
Index: branches/REL1_4/phase3/includes/Parser.php
@@ -959,7 +959,9 @@
960960 wfProfileIn( $fname );
961961
962962 $sk =& $this->mOptions->getSkin();
963 - $linktrail = wfMsgForContent('linktrail');
 963+ global $wgContLang;
 964+ $linktrail = $wgContLang->linkTrail();
 965+
964966 $bits = preg_split( EXT_LINK_BRACKETED, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
965967
966968 $s = $this->replaceFreeExternalLinks( array_shift( $bits ) );
Index: branches/REL1_4/phase3/includes/Setup.php
@@ -358,7 +358,7 @@
359359 wfSeedRandom();
360360
361361 # Placeholders in case of DB error
362 -$wgTitle = Title::newFromText( wfMsgForContent( 'badtitle' ) );
 362+$wgTitle = Title::makeTitle( NS_SPECIAL, 'Error' );
363363 $wgArticle = new Article($wgTitle);
364364
365365 wfProfileOut( $fname.'-misc2' );
Index: branches/REL1_4/phase3/includes/Skin.php
@@ -83,7 +83,8 @@
8484 /**#@-*/
8585
8686 function Skin() {
87 - $this->linktrail = wfMsgForContent('linktrail');
 87+ global $wgContLang;
 88+ $this->linktrail = $wgContLang->linkTrail();
8889
8990 # Cache option lookups done very frequently
9091 $options = array( 'highlightbroken', 'hover' );
Index: branches/REL1_4/phase3/RELEASE-NOTES
@@ -118,6 +118,7 @@
119119 * Allow customization of all UI languages
120120 * use $wgForceUIMsgAsContentMsg to make regular UI messages act as content
121121 * new user option for zh users to disable language conversion
 122+* Defer message cache initialization, shaving a few ms off file cache hits
122123
123124 === Caveats ===
124125
Index: branches/REL1_4/phase3/languages/Language.php
@@ -2229,6 +2229,20 @@
22302230 function getExtraHashOptions() {
22312231 return array();
22322232 }
 2233+
 2234+ /**
 2235+ * A regular expression to match legal word-trailing characters
 2236+ * which should be merged onto a link of the form [[foo]]bar.
 2237+ * FIXME
 2238+ *
 2239+ * @return string
 2240+ * @access public
 2241+ */
 2242+ function linkTrail() {
 2243+ $trail = $this->getMessage( 'linktrail' );
 2244+ if( empty( $trail ) ) $trail = Language::linkTrail();
 2245+ return $trail;
 2246+ }
22332247 }
22342248
22352249 # This should fail gracefully if there's not a localization available

Status & tagging log