r103480 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103479‎ | r103480 | r103481 >
Date:18:11, 17 November 2011
Author:tparscal
Status:ok
Tags:
Comment:
Addressed some issues identified in review of r103447 - this could be cleaner, but it's trying to be optimized so the UI doesn't flicker during a remove/insert (such as splitting a block)
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/es.TransactionProcessor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/es.TransactionProcessor.js
@@ -101,9 +101,16 @@
102102 remove = oldNodes.length;
103103 }
104104 }
105 - parent.splice.apply(
106 - parent, [index, remove].concat( es.DocumentModel.createNodesFromData( newData ) )
107 - );
 105+ // Try to perform this in a single operation if possible, this reduces the number of UI updates
 106+ // TODO: Introduce a global for max argument length - 1024 is also assumed in es.insertIntoArray
 107+ var newNodes = es.DocumentModel.createNodesFromData( newData );
 108+ if ( newNodes.length < 1024 ) {
 109+ parent.splice.apply( parent, [index, remove].concat( newNodes ) );
 110+ } else {
 111+ parent.splice.apply( parent, [index, remove] );
 112+ // Safe to call with arbitrary length of newNodes
 113+ es.insertIntoArray( parent, index, newNodes );
 114+ }
108115 };
109116
110117 es.TransactionProcessor.prototype.getScope = function( node, data ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r103447Reduced (dramatically) the number of re-renders on insert (but there's still ...tparscal08:03, 17 November 2011

Status & tagging log