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 @@
}
// Write childDataElements
directly
outputWrappedMetaItems(
'restore' );
- data = data.concat(
childDataElements );
+ data.push.apply( data,
childDataElements );
}
processNextWhitespace(
childDataElements[ 0 ] );
prevElement = childDataElements[ 0 ];
@@ -822,7 +822,7 @@
// comment about
wrappedWhitespace below)
wrappedWhitespace =
text;
wrappedWhitespaceIndex
= data.length;
- data = data.concat(
+ data.push.apply( data,
ve.dm.Converter.static.getDataContentFromText( wrappedWhitespace,
context.annotations )
);
} else {
@@ -876,12 +876,12 @@
outputWrappedMetaItems(
'restore' );
// We were already
wrapping in a paragraph,
// so the leading
whitespace must be output
- data = data.concat(
+ data.push.apply( data,
ve.dm.Converter.static.getDataContentFromText( matches[ 1 ],
context.annotations )
);
}
// Output the text sans
whitespace
- data = data.concat(
+ data.push.apply( data,
ve.dm.Converter.static.getDataContentFromText( matches[ 2 ],
context.annotations )
);
@@ -894,7 +894,7 @@
// because we have to apply the
correct annotations.
wrappedWhitespace = matches[ 3
];
wrappedWhitespaceIndex =
data.length;
- data = data.concat(
+ data.push.apply( data,
ve.dm.Converter.static.getDataContentFromText( wrappedWhitespace,
context.annotations )
);
prevElement = wrappingParagraph;
@@ -931,7 +931,7 @@
}
// Annotate the text and output it
- data = data.concat(
+ data.push.apply( data,
ve.dm.Converter.static.getDataContentFromText( text, context.annotations )
);
break;
--
To view, visit https://gerrit.wikimedia.org/r/314175
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1cb6dc2077138c44a27faceb3b6c73fac9e55dff
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: DLynch <[email protected]>
Gerrit-Reviewer: Divec <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits