r41952 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41951‎ | r41952 | r41953 >
Date:22:19, 10 October 2008
Author:mrzman
Status:old
Tags:
Comment:
Adding file cache to the parser to improve rendering time on pages with several uses of the same image; designed with input from Brion and Tim. Cache size is limited to 1000.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -103,6 +103,7 @@
104104 var $mTplExpandCache; // empty-frame expansion cache
105105 var $mTplRedirCache, $mTplDomCache, $mHeadings, $mDoubleUnderscores;
106106 var $mExpensiveFunctionCount; // number of expensive parser function calls
 107+ var $mFileCache;
107108
108109 # Temporary
109110 # These are variables reset at least once per parse regardless of $clearState
@@ -229,6 +230,7 @@
230231 $this->mHeadings = array();
231232 $this->mDoubleUnderscores = array();
232233 $this->mExpensiveFunctionCount = 0;
 234+ $this->mFileCache = array();
233235
234236 # Fix cloning
235237 if ( isset( $this->mPreprocessor ) && $this->mPreprocessor->parser !== $this ) {
@@ -4292,8 +4294,18 @@
42934295 return $sk->link( $title );
42944296 }
42954297
 4298+ # Get the file
 4299+ $imagename = $title->getDBkey();
 4300+ if ( isset( $this->mFileCache[$imagename][$time] ) ) {
 4301+ $file = $this->mFileCache[$imagename][$time];
 4302+ } else {
 4303+ $file = wfFindFile( $title, $time );
 4304+ if ( !(count( $this->mFileCache ) <= 1000) ) {
 4305+ $this->mFileCache = array();
 4306+ }
 4307+ $this->mFileCache[$imagename][$time] = $file;
 4308+ }
42964309 # Get parameter map
4297 - $file = wfFindFile( $title, $time );
42984310 $handler = $file ? $file->getHandler() : false;
42994311
43004312 list( $paramMap, $mwArray ) = $this->getImageParams( $handler );
Index: trunk/phase3/RELEASE-NOTES
@@ -165,6 +165,8 @@
166166 * Added the ability to display user edit counts in Special:ListUsers. Off by
167167 default, enabled with $wgEdititis = true (named after the medical condition
168168 marked by unhealthy obsession with edit counts).
 169+* Added a file cache to the parser to improve page rendering time on pages with
 170+ several uses of the same image.
169171
170172 === Bug fixes in 1.14 ===
171173

Follow-up revisions

RevisionCommit summaryAuthorDate
r42013Cleanup for r41952: > is usually easier to understand than !<= :)brion02:38, 13 October 2008

Status & tagging log