r104104 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104103‎ | r104104 | r104105 >
Date:23:37, 23 November 2011
Author:tparscal
Status:resolved (Comments)
Tags:
Comment:
Switched to a WAY faster method of updating annotated retained regions
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/es.TransactionProcessor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/es.TransactionProcessor.js
@@ -175,7 +175,8 @@
176176 var i,
177177 j,
178178 length,
179 - annotation;
 179+ annotation,
 180+ changes = 0;
180181 // Handle annotations
181182 if ( this.set.length ) {
182183 for ( i = 0, length = this.set.length; i < length; i++ ) {
@@ -193,6 +194,7 @@
194195 }
195196 }
196197 }
 198+ changes++;
197199 }
198200 if ( this.clear.length ) {
199201 for ( i = 0, length = this.clear.length; i < length; i++ ) {
@@ -212,12 +214,13 @@
213215 }
214216 }
215217 }
 218+ changes++;
216219 }
217 - if ( update ) {
218 - var updates = this.model.selectNodes( new es.Range( this.cursor, to ) );
219 - for ( i = 0; i < updates.length; i++ ) {
220 - updates[i].node.emit( 'update' );
221 - }
 220+ if ( update && changes ) {
 221+ var from = this.model.getNodeFromOffset( this.cursor );
 222+ this.model.traverseLeafNodes( function( node ) {
 223+ node.emit( 'update' );
 224+ }, from );
222225 }
223226 };
224227

Comments

#Comment by Catrope (talk | contribs)   13:07, 24 November 2011

This is actually slower in the general case (for large documents), but r104106 fixes that.

Status & tagging log