Esanders has uploaded a new change for review.
https://gerrit.wikimedia.org/r/76100
Change subject: Quick optimisation to avoid containsComparableForSerialization
......................................................................
Quick optimisation to avoid containsComparableForSerialization
As that method makes expensive ve.compare calls, we can quickly
avoid most cases by testing AnnotationSet#contains first.
On page load this reduces the number of ve.compare calls on
[[:en:Argentina]] from ~6,000,000 to about ~2,000.
We can optimise this further, but this is a good simple start.
Bug: 52013
Change-Id: Ie3b4517fd13383c48acb64b3c4e82051c34e7484
---
M modules/ve/dm/ve.dm.Converter.js
1 file changed, 9 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/00/76100/1
diff --git a/modules/ve/dm/ve.dm.Converter.js b/modules/ve/dm/ve.dm.Converter.js
index 5e2a520..15bc8c1 100644
--- a/modules/ve/dm/ve.dm.Converter.js
+++ b/modules/ve/dm/ve.dm.Converter.js
@@ -76,7 +76,10 @@
targetSetOpen = targetSet.clone();
for ( i = 0, len = currentSet.getLength(); i < len; i++ ) {
annotation = currentSet.get( i );
- if ( !targetSetOpen.containsComparableForSerialization(
annotation ) ) {
+ if (
+ !targetSetOpen.contains( annotation ) &&
+ !targetSetOpen.containsComparableForSerialization(
annotation )
+ ) {
startClosingAt = i;
break;
} else {
@@ -97,7 +100,10 @@
// Open annotations as needed
for ( i = 0, len = targetSet.getLength(); i < len; i++ ) {
annotation = targetSet.get( i );
- if ( !currentSetOpen.containsComparableForSerialization(
annotation ) ) {
+ if (
+ !currentSetOpen.contains( annotation ) &&
+ !currentSetOpen.containsComparableForSerialization(
annotation )
+ ) {
open( annotation );
// Add to currentClone
currentSet.push( annotation );
@@ -1203,7 +1209,7 @@
text = '';
}
// Close any remaining annotations
- ve.dm.Converter.openAndCloseAnnotations(
annotationStack, new ve.dm.AnnotationSet(),
+ ve.dm.Converter.openAndCloseAnnotations(
annotationStack, new ve.dm.AnnotationSet( this.store ),
openAnnotation, closeAnnotation
);
// Put the annotated nodes in the DOM
--
To view, visit https://gerrit.wikimedia.org/r/76100
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie3b4517fd13383c48acb64b3c4e82051c34e7484
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits