* and does not rely on global state or the database.
*/
class Title {
- /** @var MapCacheLRU */
+ /** @var HashBagOStuff */
static private $titleCache = null;
/**
throw new MWException( '$text must be a string, given an object' );
}
- $cache = self::getTitleCache();
+ $titleCache = self::getTitleCache();
- /**
- * Wiki pages often contain multiple links to the same page.
- * Title normalization and parsing can become expensive on
- * pages with many links, so we can save a little time by
- * caching them.
- *
- * In theory these are value objects and won't get changed...
- */
- if ( $defaultNamespace == NS_MAIN && $cache->has( $text ) ) {
- return $cache->get( $text );
+ // Wiki pages often contain multiple links to the same page.
+ // Title normalization and parsing can become expensive on pages with many
+ // links, so we can save a little time by caching them.
+ // In theory these are value objects and won't get changed...
+ if ( $defaultNamespace == NS_MAIN ) {
+ $t = $titleCache->get( $text );
+ if ( $t ) {
+ return $t;
+ }
}
- # Convert things like é ā or 〗 into normalized (bug 14952) text
+ // Convert things like é ā or 〗 into normalized (bug 14952) text
$filteredText = Sanitizer::decodeCharReferencesAndNormalize( $text );
$t = new Title();
$t->secureAndSplit();
if ( $defaultNamespace == NS_MAIN ) {
- $cache->set( $text, $t );
+ $titleCache->set( $text, $t );
}
return $t;
}
}
/**
- * @return MapCacheLRU
+ * @return HashBagOStuff
*/
private static function getTitleCache() {
if ( self::$titleCache == null ) {
- self::$titleCache = new MapCacheLRU( self::CACHE_MAX );
+ self::$titleCache = new HashBagOStuff( array( 'maxKeys' => self::CACHE_MAX ) );
}
return self::$titleCache;
}