r113245 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113244‎ | r113245 | r113246 >
Date:16:29, 7 March 2012
Author:gwicke
Status:deferred
Tags:
Comment:
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) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.TokenTransformManager.js
@@ -458,11 +458,6 @@
459459 this.tailAccumulator = res.async;
460460 this.tokenCB = res.async.getParentCB ( 'sibling' );
461461 }
462 -
463 - // The next processed chunk should call back as a sibling to last
464 - // accumulator, if any.
465 - //if ( res.async ) {
466 - //}
467462 };
468463
469464 /**
@@ -952,21 +947,36 @@
953948 */
954949 TokenAccumulator.prototype._returnTokens =
955950 function ( reference, tokens, notYetDone, allTokensProcessed ) {
956 - var res,
957 - cb,
 951+ var cb,
958952 returnTokens = [];
959953
 954+
960955 if ( ! notYetDone ) {
961956 this.outstanding--;
962957 }
963958
964959 //console.warn( 'TokenAccumulator._returnTokens' );
965960 if ( reference === 'child' ) {
966 - tokens = tokens.concat( this.accum );
 961+ var res = {};
 962+ if( !allTokensProcessed ) {
 963+ // There might be transformations missing on the returned tokens,
 964+ // re-transform to make sure those are applied too.
 965+ res = this.manager.transformTokens( tokens, this.parentCB );
 966+ tokens = res.tokens;
 967+ }
 968+
 969+ if ( !notYetDone ) {
 970+ // empty accum too
 971+ tokens = tokens.concat( this.accum );
 972+ this.accum = [];
 973+ }
967974 this.manager.env.dp( 'TokenAccumulator._returnTokens child: ',
968975 tokens, ' outstanding: ', this.outstanding );
969 - this.accum = [];
970 - this.parentCB( tokens, this.outstanding );
 976+ this.parentCB( tokens, this.outstanding, true );
 977+
 978+ if ( res.async ) {
 979+ this.parentCB = res.async.getParentCB( 'sibling' );
 980+ }
971981 return null;
972982 } else {
973983 // sibling
@@ -977,7 +987,7 @@
978988 this.manager.env.dp( 'TokenAccumulator._returnTokens: ',
979989 'sibling done and parentCB ',
980990 tokens );
981 - this.parentCB( tokens, false );
 991+ this.parentCB( tokens, false, true );
982992 return null;
983993 } else if ( this.outstanding === 1 && notYetDone ) {
984994 this.manager.env.dp( 'TokenAccumulator._returnTokens: ',
@@ -987,7 +997,7 @@
988998 // allow the sibling to go direct, and call back parent with
989999 // tokens. The internal accumulator is empty at this stage, as its
9901000 // tokens are passed to the parent when the child is done.
991 - return this.parentCB( tokens, true);
 1001+ return this.parentCB( tokens, true, true);
9921002 } else {
9931003 this.accum = this.accum.concat( tokens );
9941004 this.manager.env.dp( 'TokenAccumulator._returnTokens: sibling done, but not overall. notYetDone=',

Status & tagging log