https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113245

Revision: 113245
Author:   gwicke
Date:     2012-03-07 16:29:06 +0000 (Wed, 07 Mar 2012)
Log Message:
-----------
Start re-transformation as soon as possible in TokenAccumulator._returnTokens
to maximize IO concurrency. Signal that all tokens are fully transformed to
callbacks called from TokenAccumulator._returnTokens. The result should be a
single re-transformation when entering the callback chain, and only if the
transform does not signal that it took care of full transformation itself.
Template expansion would set this flag, as the nested transform pipeline
processes all tokens to the end of phase async12.

Modified Paths:
--------------
    
trunk/extensions/VisualEditor/modules/parser/mediawiki.TokenTransformManager.js

Modified: 
trunk/extensions/VisualEditor/modules/parser/mediawiki.TokenTransformManager.js
===================================================================
--- 
trunk/extensions/VisualEditor/modules/parser/mediawiki.TokenTransformManager.js 
    2012-03-07 16:24:36 UTC (rev 113244)
+++ 
trunk/extensions/VisualEditor/modules/parser/mediawiki.TokenTransformManager.js 
    2012-03-07 16:29:06 UTC (rev 113245)
@@ -458,11 +458,6 @@
                this.tailAccumulator = res.async;
                this.tokenCB = res.async.getParentCB ( 'sibling' );
        }
-
-       // The next processed chunk should call back as a sibling to last
-       // accumulator, if any.
-       //if ( res.async ) {
-       //}
 };
 
 /**
@@ -952,21 +947,36 @@
  */
 TokenAccumulator.prototype._returnTokens = 
        function ( reference, tokens, notYetDone, allTokensProcessed ) {
-       var res,
-               cb,
+       var cb,
                returnTokens = [];
 
+
        if ( ! notYetDone ) {
                this.outstanding--;
        }
 
        //console.warn( 'TokenAccumulator._returnTokens' );
        if ( reference === 'child' ) {
-               tokens = tokens.concat( this.accum );
+               var res = {};
+               if( !allTokensProcessed ) {
+                       // There might be transformations missing on the 
returned tokens,
+                       // re-transform to make sure those are applied too.
+                       res = this.manager.transformTokens( tokens, 
this.parentCB );
+                       tokens = res.tokens;
+               }
+
+               if ( !notYetDone ) {
+                       // empty accum too
+                       tokens = tokens.concat( this.accum );
+                       this.accum = [];
+               }
                this.manager.env.dp( 'TokenAccumulator._returnTokens child: ',
                                tokens, ' outstanding: ', this.outstanding );
-               this.accum = [];
-               this.parentCB( tokens, this.outstanding );
+               this.parentCB( tokens, this.outstanding, true );
+
+               if ( res.async ) {
+                       this.parentCB = res.async.getParentCB( 'sibling' );
+               }
                return null;
        } else {
                // sibling
@@ -977,7 +987,7 @@
                        this.manager.env.dp( 'TokenAccumulator._returnTokens: ',
                                        'sibling done and parentCB ',
                                        tokens );
-                       this.parentCB( tokens, false );
+                       this.parentCB( tokens, false, true );
                        return null;
                } else if ( this.outstanding === 1 && notYetDone ) {
                        this.manager.env.dp( 'TokenAccumulator._returnTokens: ',
@@ -987,7 +997,7 @@
                        // allow the sibling to go direct, and call back parent 
with
                        // tokens. The internal accumulator is empty at this 
stage, as its
                        // tokens are passed to the parent when the child is 
done.
-                       return this.parentCB( tokens, true);
+                       return this.parentCB( tokens, true, true);
                } else {
                        this.accum  = this.accum.concat( tokens );
                        this.manager.env.dp( 'TokenAccumulator._returnTokens: 
sibling done, but not overall. notYetDone=',


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to