From ff5ba541154b05c897f4f7fe66c866d243976e7e Mon Sep 17 00:00:00 2001 From: Trevor Parscal Date: Wed, 23 Nov 2011 23:37:27 +0000 Subject: [PATCH] Switched to a WAY faster method of updating annotated retained regions --- modules/es/es.TransactionProcessor.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/es/es.TransactionProcessor.js b/modules/es/es.TransactionProcessor.js index bd07b25a9a..9d86addc8e 100644 --- a/modules/es/es.TransactionProcessor.js +++ b/modules/es/es.TransactionProcessor.js @@ -175,7 +175,8 @@ es.TransactionProcessor.prototype.applyAnnotations = function( to, update ) { var i, j, length, - annotation; + annotation, + changes = 0; // Handle annotations if ( this.set.length ) { for ( i = 0, length = this.set.length; i < length; i++ ) { @@ -193,6 +194,7 @@ es.TransactionProcessor.prototype.applyAnnotations = function( to, update ) { } } } + changes++; } if ( this.clear.length ) { for ( i = 0, length = this.clear.length; i < length; i++ ) { @@ -212,12 +214,13 @@ es.TransactionProcessor.prototype.applyAnnotations = function( to, update ) { } } } + changes++; } - if ( update ) { - var updates = this.model.selectNodes( new es.Range( this.cursor, to ) ); - for ( i = 0; i < updates.length; i++ ) { - updates[i].node.emit( 'update' ); - } + if ( update && changes ) { + var from = this.model.getNodeFromOffset( this.cursor ); + this.model.traverseLeafNodes( function( node ) { + node.emit( 'update' ); + }, from ); } };