r113853 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113852‎ | r113853 | r113854 >
Date:21:02, 14 March 2012
Author:catrope
Status:deferred
Tags:
Comment:
Factor out process() into nextOperation() and executeOperation()
Modified paths:
  • /trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.TransactionProcessor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.TransactionProcessor.js
@@ -84,15 +84,24 @@
8585
8686 /* Methods */
8787
 88+ve.dm.TransactionProcessor.prototype.nextOperation = function() {
 89+ return this.operations[this.operationIndex++] || false;
 90+};
 91+
 92+ve.dm.TransactionProcessor.prototype.executeOperation = function( op, method ) {
 93+ if ( op.type in ve.dm.TransactionProcessor.operationMap ) {
 94+ ve.dm.TransactionProcessor.operationMap[op.type][method].call( this, op );
 95+ } else {
 96+ throw 'Invalid operation error. Operation type is not supported: ' + operation.type;
 97+ }
 98+};
 99+
88100 ve.dm.TransactionProcessor.prototype.process = function( method ) {
89 - var operations = this.transaction.getOperations();
90 - for ( var i = 0, length = operations.length; i < length; i++ ) {
91 - var operation = operations[i];
92 - if ( operation.type in ve.dm.TransactionProcessor.operationMap ) {
93 - ve.dm.TransactionProcessor.operationMap[operation.type][method].call( this, operation );
94 - } else {
95 - throw 'Invalid operation error. Operation type is not supported: ' + operation.type;
96 - }
 101+ var op;
 102+ this.operations = this.transaction.getOperations();
 103+ this.operationIndex = 0;
 104+ while ( ( op = this.nextOperation() ) ) {
 105+ this.executeOperation( op, method );
97106 }
98107 };
99108

Status & tagging log