var $mLinkID;
var $mIncludeSizes, $mPPNodeCount, $mGeneratedPPNodeCount, $mHighestExpansionDepth;
var $mDefaultSort;
- var $mTplExpandCache; # empty-frame expansion cache
var $mTplRedirCache, $mTplDomCache, $mHeadings, $mDoubleUnderscores;
var $mExpensiveFunctionCount; # number of expensive parser function calls
var $mShowToc, $mForceTocPosition;
$this->mStripState = new StripState( $this->mUniqPrefix );
# Clear these on every parse, bug 4549
- $this->mTplExpandCache = $this->mTplRedirCache = $this->mTplDomCache = array();
+ $this->mTplRedirCache = $this->mTplDomCache = array();
$this->mShowToc = true;
$this->mForceTocPosition = false;
$text = $newFrame->expand( $text, PPFrame::RECOVER_ORIG );
} elseif ( $titleText !== false && $newFrame->isEmpty() ) {
# Expansion is eligible for the empty-frame cache
- if ( isset( $this->mTplExpandCache[$titleText] ) ) {
- $text = $this->mTplExpandCache[$titleText];
- } else {
- $text = $newFrame->expand( $text );
- $this->mTplExpandCache[$titleText] = $text;
- }
+ $text = $newFrame->cachedExpand( $titleText, $text );
} else {
# Uncached expansion
$text = $newFrame->expand( $text );
*/
function newChild( $args = false, $title = false, $indexOffset = 0 );
+ /**
+ * Expand a document tree node, caching the result on its parent with the given key
+ */
+ function cachedExpand( $key, $root, $flags = 0 );
+
/**
* Expand a document tree node
*/
*/
var $depth;
+ /**
+ * @var array
+ */
+ protected $childExpansionCache;
+
/**
* Construct a new preprocessor frame.
* @param Preprocessor $preprocessor The parent preprocessor
$this->titleCache = array( $this->title ? $this->title->getPrefixedDBkey() : false );
$this->loopCheckHash = array();
$this->depth = 0;
+ $this->childExpansionCache = array();
}
/**
return new PPTemplateFrame_DOM( $this->preprocessor, $this, $numberedArgs, $namedArgs, $title );
}
+ /**
+ * @throws MWException
+ * @param string|int $key
+ * @param string|PPNode_DOM|DOMDocument $root
+ * @param int $flags
+ * @return string
+ */
+ function cachedExpand( $key, $root, $flags = 0 ) {
+ // we don't have a parent, so we don't have a cache
+ return $this->expand( $root, $flags );
+ }
+
/**
* @throws MWException
* @param string|PPNode_DOM|DOMDocument $root
return $s;
}
+ /**
+ * @throws MWException
+ * @param string|int $key
+ * @param string|PPNode_DOM|DOMDocument $root
+ * @param int $flags
+ * @return string
+ */
+ function cachedExpand( $key, $root, $flags = 0 ) {
+ if ( !isset( $this->parent->childExpansionCache[$key] ) ) {
+ $this->parent->childExpansionCache[$key] = $this->expand( $root, $flags );
+ }
+ return $this->parent->childExpansionCache[$key];
+ }
+
/**
* Returns true if there are no arguments in this frame
*
*/
var $depth;
+ /**
+ * @var array
+ */
+ protected $childExpansionCache;
+
/**
* Construct a new preprocessor frame.
* @param Preprocessor $preprocessor The parent preprocessor
$this->titleCache = array( $this->title ? $this->title->getPrefixedDBkey() : false );
$this->loopCheckHash = array();
$this->depth = 0;
+ $this->childExpansionCache = array();
}
/**
return new PPTemplateFrame_Hash( $this->preprocessor, $this, $numberedArgs, $namedArgs, $title );
}
+ /**
+ * @throws MWException
+ * @param string|int $key
+ * @param string|PPNode_Hash|DOMDocument $root
+ * @param int $flags
+ * @return string
+ */
+ function cachedExpand( $key, $root, $flags = 0 ) {
+ // we don't have a parent, so we don't have a cache
+ return $this->expand( $root, $flags );
+ }
+
/**
* @throws MWException
* @param string|PPNode$root
return $s;
}
+ /**
+ * @throws MWException
+ * @param string|int $key
+ * @param string|PPNode_Hash|DOMDocument $root
+ * @param int $flags
+ * @return string
+ */
+ function cachedExpand( $key, $root, $flags = 0 ) {
+ if ( !isset( $this->parent->childExpansionCache[$key] ) ) {
+ $this->parent->childExpansionCache[$key] = $this->expand( $root, $flags );
+ }
+ return $this->parent->childExpansionCache[$key];
+ }
+
/**
* Returns true if there are no arguments in this frame
*