Switched to a WAY faster method of updating annotated retained regions

This commit is contained in:
Trevor Parscal 2011-11-23 23:37:27 +00:00
parent 3ed6544fe2
commit ff5ba54115

View file

@ -175,7 +175,8 @@ es.TransactionProcessor.prototype.applyAnnotations = function( to, update ) {
var i, var i,
j, j,
length, length,
annotation; annotation,
changes = 0;
// Handle annotations // Handle annotations
if ( this.set.length ) { if ( this.set.length ) {
for ( i = 0, length = this.set.length; i < length; i++ ) { 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 ) { if ( this.clear.length ) {
for ( i = 0, length = this.clear.length; i < length; i++ ) { for ( i = 0, length = this.clear.length; i < length; i++ ) {
@ -212,12 +214,13 @@ es.TransactionProcessor.prototype.applyAnnotations = function( to, update ) {
} }
} }
} }
changes++;
} }
if ( update ) { if ( update && changes ) {
var updates = this.model.selectNodes( new es.Range( this.cursor, to ) ); var from = this.model.getNodeFromOffset( this.cursor );
for ( i = 0; i < updates.length; i++ ) { this.model.traverseLeafNodes( function( node ) {
updates[i].node.emit( 'update' ); node.emit( 'update' );
} }, from );
} }
}; };