Krinkle has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/91337


Change subject: Remove simpleArray utilities from ve.js and use oojs instead
......................................................................

Remove simpleArray utilities from ve.js and use oojs instead

Change-Id: I23710ff50378f4069b8a0dea89f0491884acd377
---
M modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js
M modules/ve-mw/dm/nodes/ve.dm.MWInlineImageNode.js
M modules/ve/dm/ve.dm.AnnotationSet.js
M modules/ve/dm/ve.dm.ModelRegistry.js
M modules/ve/ui/ve.ui.ToolFactory.js
M modules/ve/ve.js
6 files changed, 10 insertions(+), 90 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/37/91337/1

diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js 
b/modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js
index d97f2c7..bdd6485 100644
--- a/modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js
+++ b/modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js
@@ -109,7 +109,7 @@
        }
 
        // Store unrecognized classes so we can restore them on the way out
-       attributes.unrecognizedClasses = ve.simpleArrayDifference( classes, 
recognizedClasses );
+       attributes.unrecognizedClasses = OO.simpleArrayDifference( classes, 
recognizedClasses );
 
        dataElement = { 'type': this.name, 'attributes': attributes };
 
@@ -175,7 +175,7 @@
        }
 
        if ( dataElement.attributes.unrecognizedClasses ) {
-               classes = ve.simpleArrayUnion( classes, 
dataElement.attributes.unrecognizedClasses );
+               classes = OO.simpleArrayUnion( classes, 
dataElement.attributes.unrecognizedClasses );
        }
 
        if (
diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWInlineImageNode.js 
b/modules/ve-mw/dm/nodes/ve.dm.MWInlineImageNode.js
index fa7d630..8d2ce88 100644
--- a/modules/ve-mw/dm/nodes/ve.dm.MWInlineImageNode.js
+++ b/modules/ve-mw/dm/nodes/ve.dm.MWInlineImageNode.js
@@ -125,7 +125,7 @@
        }
 
        // Store unrecognized classes so we can restore them on the way out
-       attributes.unrecognizedClasses = ve.simpleArrayDifference( classes, 
recognizedClasses );
+       attributes.unrecognizedClasses = OO.simpleArrayDifference( classes, 
recognizedClasses );
 
        dataElement = { 'type': this.name, 'attributes': attributes };
 
@@ -166,7 +166,7 @@
        }
 
        if ( data.attributes.unrecognizedClasses ) {
-               classes = ve.simpleArrayUnion( classes, 
data.attributes.unrecognizedClasses );
+               classes = OO.simpleArrayUnion( classes, 
data.attributes.unrecognizedClasses );
        }
 
        if (
diff --git a/modules/ve/dm/ve.dm.AnnotationSet.js 
b/modules/ve/dm/ve.dm.AnnotationSet.js
index cfa368e..7b19339 100644
--- a/modules/ve/dm/ve.dm.AnnotationSet.js
+++ b/modules/ve/dm/ve.dm.AnnotationSet.js
@@ -361,7 +361,7 @@
  * @param {ve.dm.AnnotationSet} set Set to add to the set
  */
 ve.dm.AnnotationSet.prototype.addSet = function ( set ) {
-       this.storeIndexes = ve.simpleArrayUnion( this.getIndexes(), 
set.getIndexes() );
+       this.storeIndexes = OO.simpleArrayUnion( this.getIndexes(), 
set.getIndexes() );
 };
 
 /**
@@ -449,7 +449,7 @@
  * @param {ve.dm.AnnotationSet} set Set to remove from the set
  */
 ve.dm.AnnotationSet.prototype.removeSet = function ( set ) {
-       this.storeIndexes = ve.simpleArrayDifference( this.getIndexes(), 
set.getIndexes() );
+       this.storeIndexes = OO.simpleArrayDifference( this.getIndexes(), 
set.getIndexes() );
 };
 
 /**
@@ -459,7 +459,7 @@
  * @param {ve.dm.AnnotationSet} set Set to intersect with the set
  */
 ve.dm.AnnotationSet.prototype.removeNotInSet = function ( set ) {
-       this.storeIndexes = ve.simpleArrayIntersection( this.getIndexes(), 
set.getIndexes() );
+       this.storeIndexes = OO.simpleArrayIntersection( this.getIndexes(), 
set.getIndexes() );
 };
 
 /**
diff --git a/modules/ve/dm/ve.dm.ModelRegistry.js 
b/modules/ve/dm/ve.dm.ModelRegistry.js
index 911c4a1..6550a8a 100644
--- a/modules/ve/dm/ve.dm.ModelRegistry.js
+++ b/modules/ve/dm/ve.dm.ModelRegistry.js
@@ -242,7 +242,7 @@
                        // Queue string matches and regexp matches separately
                        queue = queue.concat( ve.getProp( 
reg.modelsByTypeAndTag, 1, types[i], tag ) || [] );
                        if ( excludeTypes ) {
-                               queue = ve.simpleArrayDifference( queue, 
excludeTypes );
+                               queue = OO.simpleArrayDifference( queue, 
excludeTypes );
                        }
                        queue2 = queue2.concat( matchTypeRegExps( types[i], 
tag, true ) );
                }
@@ -282,7 +282,7 @@
                        // Queue string and regexp matches separately
                        queue = queue.concat( ve.getProp( 
reg.modelsByTypeAndTag, 0, types[i], tag ) || [] );
                        if ( excludeTypes ) {
-                               queue = ve.simpleArrayDifference( queue, 
excludeTypes );
+                               queue = OO.simpleArrayDifference( queue, 
excludeTypes );
                        }
                        queue2 = queue2.concat( matchTypeRegExps( types[i], 
tag, false ) );
                }
diff --git a/modules/ve/ui/ve.ui.ToolFactory.js 
b/modules/ve/ui/ve.ui.ToolFactory.js
index 444a847..5e82971 100644
--- a/modules/ve/ui/ve.ui.ToolFactory.js
+++ b/modules/ve/ui/ve.ui.ToolFactory.js
@@ -29,7 +29,7 @@
                used = {};
 
        // Collect included and not excluded tools
-       included = ve.simpleArrayDifference( this.extract( include ), 
this.extract( exclude ) );
+       included = OO.simpleArrayDifference( this.extract( include ), 
this.extract( exclude ) );
 
        // Promotion
        promoted = this.extract( promote, used );
diff --git a/modules/ve/ve.js b/modules/ve/ve.js
index 8a79553..4ca51c7 100644
--- a/modules/ve/ve.js
+++ b/modules/ve/ve.js
@@ -151,86 +151,6 @@
        ve.indexOf = $.inArray;
 
        /**
-        * Compute the union (duplicate-free merge) of a set of arrays.
-        *
-        * Arrays values must be convertable to object keys (strings)
-        *
-        * By building an object (with the values for keys) in parallel with
-        * the array, a new item's existence in the union can be computed faster
-        *
-        * @param {Array...} arrays Arrays to union
-        * @returns {Array} Union of the arrays
-        */
-       ve.simpleArrayUnion = function () {
-               var i, ilen, j, jlen, arr, obj = {}, result = [];
-               for ( i = 0, ilen = arguments.length; i < ilen; i++ ) {
-                       arr = arguments[i];
-                       for ( j = 0, jlen = arr.length; j < jlen; j++ ) {
-                               if ( !obj[arr[j]] ) {
-                                       obj[arr[j]] = true;
-                                       result.push( arr[j] );
-                               }
-                       }
-               }
-               return result;
-       };
-
-       /**
-        * Compute the intersection of two arrays (items in both arrays).
-        *
-        * Arrays values must be convertable to object keys (strings)
-        *
-        * @param {Array} a First array
-        * @param {Array} b Second array
-        * @returns {Array} Intersection of arrays
-        */
-       ve.simpleArrayIntersection = function ( a, b ) {
-               return ve.simpleArrayCombine( a, b, true );
-       };
-
-       /**
-        * Compute the difference of two arrays (items in 'a' but not 'b').
-        *
-        * Arrays values must be convertable to object keys (strings)
-        *
-        * @param {Array} a First array
-        * @param {Array} b Second array
-        * @returns {Array} Intersection of arrays
-        */
-       ve.simpleArrayDifference = function ( a, b ) {
-               return ve.simpleArrayCombine( a, b, false );
-       };
-
-       /**
-        * Combine arrays (intersection or difference).
-        *
-        * An intersection checks the item exists in 'b' while difference 
checks it doesn't.
-        *
-        * Arrays values must be convertable to object keys (strings)
-        *
-        * By building an object (with the values for keys) of 'b' we can
-        * compute the result faster
-        *
-        * @param {Array} a First array
-        * @param {Array} b Second array
-        * @param {boolean} includeB Include items in 'b'
-        * @returns {Array} Combination (intersection or difference) of arrays
-        */
-       ve.simpleArrayCombine = function ( a, b, includeB ) {
-               var i, ilen, isInB, bObj = {}, result = [];
-               for ( i = 0, ilen = b.length; i < ilen; i++ ) {
-                       bObj[b[i]] = true;
-               }
-               for ( i = 0, ilen = a.length; i < ilen; i++ ) {
-                       isInB = !!bObj[a[i]];
-                       if ( isInB === includeB ) {
-                               result.push( a[i] );
-                       }
-               }
-               return result;
-       };
-
-       /**
         * Merge properties of one or more objects into another.
         * Preserves original object's inheritance (e.g. Array, Object, 
whatever).
         * In case of array or array-like objects only the indexed properties

-- 
To view, visit https://gerrit.wikimedia.org/r/91337
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I23710ff50378f4069b8a0dea89f0491884acd377
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to