}
/**
+ * Get all magic words from cache.
* @return array
*/
function getMagicWords() {
return self::$dataCache->getItem( $this->mCode, 'magicWords' );
}
+ /**
+ * Run the LanguageGetMagic hook once.
+ */
protected function doMagicHook() {
if ( $this->mMagicHookDone ) {
return;
* @param $mw
*/
function getMagic( $mw ) {
- $this->doMagicHook();
+ // Saves a function call
+ if ( ! $this->mMagicHookDone ) {
+ $this->doMagicHook();
+ }
if ( isset( $this->mMagicExtensions[$mw->mId] ) ) {
$rawEntry = $this->mMagicExtensions[$mw->mId];
} else {
- $magicWords = $this->getMagicWords();
- if ( isset( $magicWords[$mw->mId] ) ) {
- $rawEntry = $magicWords[$mw->mId];
- } else {
- $rawEntry = false;
- }
+ $rawEntry = self::$dataCache->getSubitem(
+ $this->mCode, 'magicWords', $mw->mId );
}
if ( !is_array( $rawEntry ) ) {