mediawiki.jqueryMsg: Remove 'astCache'
authorBartosz Dziewoński <matma.rex@gmail.com>
Fri, 16 Oct 2015 20:08:41 +0000 (22:08 +0200)
committerKrinkle <krinklemail@gmail.com>
Tue, 27 Oct 2015 04:46:03 +0000 (04:46 +0000)
All it does is cause problems.

Bug: T54042
Change-Id: I955ee61f6c0040203959ab8f45efb56a32431768

resources/src/mediawiki/mediawiki.jqueryMsg.js

index de63a18..0a24454 100644 (file)
        };
 
        mw.jqueryMsg.parser.prototype = {
-               /**
-                * Cache mapping MediaWiki message keys and the value onlyCurlyBraceTransform, to the AST of the message.
-                *
-                * In most cases, the message is a string so this is identical.
-                * (This is why we would like to move this functionality server-side).
-                *
-                * The two parts of the key are separated by colon.  For example:
-                *
-                *     "message-key:true": ast
-                *
-                * if they key is "message-key" and onlyCurlyBraceTransform is true.
-                *
-                * This cache is shared by all instances of mw.jqueryMsg.parser.
-                *
-                * NOTE: We promise, it's static - when you create this empty object
-                * in the prototype, each new instance of the class gets a reference
-                * to the same object.
-                *
-                * @static
-                * @property {Object}
-                */
-               astCache: {},
-
                /**
                 * Where the magic happens.
                 * Parses a message from the key, and swaps in replacements as necessary, wraps in jQuery
                 * @return {string|Array} string of '[key]' if message missing, simple string if possible, array of arrays if needs parsing
                 */
                getAst: function ( key ) {
-                       var wikiText,
-                               cacheKey = [ key, this.settings.onlyCurlyBraceTransform ].join( ':' );
-
-                       if ( this.astCache[ cacheKey ] === undefined ) {
-                               wikiText = this.settings.messages.get( key );
-                               if ( typeof wikiText !== 'string' ) {
-                                       wikiText = '\\[' + key + '\\]';
-                               }
-                               this.astCache[ cacheKey ] = this.wikiTextToAst( wikiText );
+                       var wikiText = this.settings.messages.get( key );
+                       if ( typeof wikiText !== 'string' ) {
+                               wikiText = '\\[' + key + '\\]';
                        }
-                       return this.astCache[ cacheKey ];
+                       return this.wikiTextToAst( wikiText );
                },
 
                /**
                        // I am deferring the work of turning it into prototypes & objects. It's quite fast enough
                        // finally let's do some actual work...
 
-                       // If you add another possible rootExpression, you must update the astCache key scheme.
                        result = start( this.settings.onlyCurlyBraceTransform ? curlyBraceTransformExpression : expression );
 
                        /*