[MediaWiki-commits] [Gerrit] VisualEditor/VisualEditor[master]: Replace Array#concat with Array#push in converter
jenkins-bot has submitted this change and it was merged. Change subject: Replace Array#concat with Array#push in converter .. Replace Array#concat with Array#push in converter When converting long articles this appears to be much faster. Testing on [[Barack Obama]]: * Chrome: 580ms -> 480ms * Firefox: 2400ms -> 720ms Change-Id: I1cb6dc2077138c44a27faceb3b6c73fac9e55dff --- M src/dm/ve.dm.Converter.js 1 file changed, 12 insertions(+), 12 deletions(-) Approvals: DLynch: Looks good to me, approved Jforrester: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/src/dm/ve.dm.Converter.js b/src/dm/ve.dm.Converter.js index 1da2d36..ce89bb4 100644 --- a/src/dm/ve.dm.Converter.js +++ b/src/dm/ve.dm.Converter.js @@ -548,7 +548,7 @@ if ( wrappedMetaItems[ i ].type && wrappedMetaItems[ i ].type.charAt( 0 ) !== '/' ) { if ( wrappedMetaItems[ i ].internal && wrappedMetaItems[ i ].internal.whitespace ) { if ( whitespaceTreatment === 'restore' ) { - toInsert = toInsert.concat( ve.dm.Converter.static.getDataContentFromText( + toInsert.push.apply( toInsert, ve.dm.Converter.static.getDataContentFromText( wrappedMetaItems[ i ].internal.whitespace[ 0 ], context.annotations ) ); delete wrappedMetaItems[ i ].internal; @@ -565,7 +565,7 @@ // This is horrible and this whole system desperately needs to be rewritten ve.batchSplice( data, wrappedWhitespaceIndex, 0, toInsert ); } else { - data = data.concat( toInsert ); + data.push.apply( data, toInsert ); } wrappedMetaItems = []; } @@ -707,7 +707,7 @@ } } outputWrappedMetaItems( 'restore' ); - data = data.concat( childDataElements ); + data.push.apply( data, childDataElements ); // Clear wrapped whitespace wrappedWhitespace = ''; } else { @@ -725,7 +725,7 @@ // Queue wrapped meta items only if it's actually possible for us to move them out // of the wrapper if ( context.inWrapper && context.canCloseWrapper ) { - wrappedMetaItems = wrappedMetaItems.concat( childDataElements ); + wrappedMetaItems.push.apply( wrappedMetaItems, childDataElements ); if ( wrappedWhitespace !== '' ) { data.splice( wrappedWhitespaceIndex, wrappedWhitespace.length ); addWhitespace( childDataElements[ 0 ], 0, wrappedWhitespace ); @@ -734,7 +734,7 @@ } } else { outputWrappedMetaItems( 'restore' ); - data = data.concat( childDataElements ); + data.push.apply( data, childDataElements ); processNextWhitespace( childDataElements[ 0 ] ); prevElement = childDataElements[ 0 ]; } @@ -786,7 +786,7 @@ // Recursion // Opening and closing elements are added by the recursion too outputWrappedMetaItems( 'restore' ); - data = data.concat( + data.push.apply( data, this.getDataFromDomSubtree( childNode, childDataElements[ 0 ], new ve.dm.AnnotationSet( this.store ) ) @@ -797,7 +797,7 @@ }
[MediaWiki-commits] [Gerrit] VisualEditor/VisualEditor[master]: Replace Array#concat with Array#push in converter
Esanders has uploaded a new change for review. https://gerrit.wikimedia.org/r/314175 Change subject: Replace Array#concat with Array#push in converter .. Replace Array#concat with Array#push in converter When converting long articles this appears to be much faster. Testing on [[Barack Obama]]: * Chrome: 580ms -> 480ms * Firefox: 2400ms -> 720ms Change-Id: I1cb6dc2077138c44a27faceb3b6c73fac9e55dff --- M src/dm/ve.dm.Converter.js 1 file changed, 12 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor refs/changes/75/314175/1 diff --git a/src/dm/ve.dm.Converter.js b/src/dm/ve.dm.Converter.js index 1da2d36..ce89bb4 100644 --- a/src/dm/ve.dm.Converter.js +++ b/src/dm/ve.dm.Converter.js @@ -548,7 +548,7 @@ if ( wrappedMetaItems[ i ].type && wrappedMetaItems[ i ].type.charAt( 0 ) !== '/' ) { if ( wrappedMetaItems[ i ].internal && wrappedMetaItems[ i ].internal.whitespace ) { if ( whitespaceTreatment === 'restore' ) { - toInsert = toInsert.concat( ve.dm.Converter.static.getDataContentFromText( + toInsert.push.apply( toInsert, ve.dm.Converter.static.getDataContentFromText( wrappedMetaItems[ i ].internal.whitespace[ 0 ], context.annotations ) ); delete wrappedMetaItems[ i ].internal; @@ -565,7 +565,7 @@ // This is horrible and this whole system desperately needs to be rewritten ve.batchSplice( data, wrappedWhitespaceIndex, 0, toInsert ); } else { - data = data.concat( toInsert ); + data.push.apply( data, toInsert ); } wrappedMetaItems = []; } @@ -707,7 +707,7 @@ } } outputWrappedMetaItems( 'restore' ); - data = data.concat( childDataElements ); + data.push.apply( data, childDataElements ); // Clear wrapped whitespace wrappedWhitespace = ''; } else { @@ -725,7 +725,7 @@ // Queue wrapped meta items only if it's actually possible for us to move them out // of the wrapper if ( context.inWrapper && context.canCloseWrapper ) { - wrappedMetaItems = wrappedMetaItems.concat( childDataElements ); + wrappedMetaItems.push.apply( wrappedMetaItems, childDataElements ); if ( wrappedWhitespace !== '' ) { data.splice( wrappedWhitespaceIndex, wrappedWhitespace.length ); addWhitespace( childDataElements[ 0 ], 0, wrappedWhitespace ); @@ -734,7 +734,7 @@ } } else { outputWrappedMetaItems( 'restore' ); - data = data.concat( childDataElements ); + data.push.apply( data, childDataElements ); processNextWhitespace( childDataElements[ 0 ] ); prevElement = childDataElements[ 0 ]; } @@ -786,7 +786,7 @@ // Recursion // Opening and closing elements are added by the recursion too outputWrappedMetaItems( 'restore' ); - data = data.concat( + data.push.apply( data, this.getDataFromDomSubtree( childNode, childDataElements[ 0 ], new ve.dm.AnnotationSet( this.store ) ) @@ -797,7 +797,7 @@ }