resources: Update CLDRPluralRuleParser to v1.3.2-pre
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 4 Oct 2018 21:17:30 +0000 (22:17 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Thu, 4 Oct 2018 21:17:30 +0000 (22:17 +0100)
Not yet tagged as release, but updating ahead of that for the
performance improvement that landed with
https://github.com/santhoshtr/CLDRPluralRuleParser/commit/a7782ca.

This is particularly impactful on calls to mw.msg() during the
critical path, due to this library being called by jqueryMsg,
which is used by mw.Message#text, which mw.msg() calls by default.

Particularly seen in the startup code from ULS modules.

Bug: T127328
Change-Id: Ic865e7077d1053c65f7ae1633c60bf52104731b7

maintenance/resources/foreign-resources.yaml
resources/lib/CLDRPluralRuleParser/CLDRPluralRuleParser.js

index c610b3c..70068dc 100644 (file)
@@ -36,8 +36,8 @@
 
 CLDRPluralRuleParser:
   type: file
-  src: https://raw.githubusercontent.com/santhoshtr/CLDRPluralRuleParser/v1.1.3/src/CLDRPluralRuleParser.js
-  integrity: sha384-Y0qxTEDVQgh+N5In+vLbZLL2H7PEROnicj8vxof0mxR8kXcGysGE6OcF+cS+Ao0u
+  src: https://raw.githubusercontent.com/santhoshtr/CLDRPluralRuleParser/0dda851/src/CLDRPluralRuleParser.js
+  integrity: sha384-M4taeYYG2+9Ob1/La16iO+zlRRmBV5lBR3xUKkQT6kfkJ0aLbCi6yc0RYI1BDzdh
 
 easy-deflate:
   type: multi-file
index 1491e3d..73268d4 100644 (file)
@@ -6,7 +6,6 @@
  * Released under the MIT license
  * http://opensource.org/licenses/MIT
  *
- * @version 0.1.0
  * @source https://github.com/santhoshtr/CLDRPluralRuleParser
  * @author Santhosh Thottingal <santhosh.thottingal@gmail.com>
  * @author Timo Tijhof
@@ -26,6 +25,7 @@
                // AMD. Register as an anonymous module.
                define(factory);
        } else if (typeof exports === 'object') {
+               /* global module */
                // Node. Does not work with strict CommonJS, but
                // only CommonJS-like environments that support module.exports,
                // like Node.
@@ -322,9 +322,9 @@ function pluralRuleParser(rule, number) {
                        return null;
                }
 
-               debug(' -- passed ' + parseInt(result[0], 10) + ' ' + result[2] + ' ' + parseInt(result[4], 10));
+               debug(' -- passed ', parseInt(result[0], 10), result[2], parseInt(result[4], 10));
 
-               return parseInt(result[0], 10) % parseInt(result[4], 10);
+               return parseFloat(result[0]) % parseInt(result[4], 10);
        }
 
        function not() {
@@ -344,7 +344,7 @@ function pluralRuleParser(rule, number) {
                var result = sequence([expression, whitespace, choice([_is_]), whitespace, value]);
 
                if (result !== null) {
-                       debug(' -- passed is : ' + result[0] + ' == ' + parseInt(result[4], 10));
+                       debug(' -- passed is :', result[0], ' == ', parseInt(result[4], 10));
 
                        return result[0] === parseInt(result[4], 10);
                }
@@ -361,7 +361,7 @@ function pluralRuleParser(rule, number) {
                );
 
                if (result !== null) {
-                       debug(' -- passed isnot: ' + result[0] + ' != ' + parseInt(result[4], 10));
+                       debug(' -- passed isnot: ', result[0], ' != ', parseInt(result[4], 10));
 
                        return result[0] !== parseInt(result[4], 10);
                }
@@ -376,7 +376,7 @@ function pluralRuleParser(rule, number) {
                        result = sequence([expression, whitespace, _isnot_sign_, whitespace, rangeList]);
 
                if (result !== null) {
-                       debug(' -- passed not_in: ' + result[0] + ' != ' + result[4]);
+                       debug(' -- passed not_in: ', result[0], ' != ', result[4]);
                        range_list = result[4];
 
                        for (i = 0; i < range_list.length; i++) {
@@ -459,12 +459,12 @@ function pluralRuleParser(rule, number) {
                );
 
                if (result !== null) {
-                       debug(' -- passed _in:' + result);
+                       debug(' -- passed _in:', result);
 
                        range_list = result[5];
 
                        for (i = 0; i < range_list.length; i++) {
-                               if (parseInt(range_list[i], 10) === parseInt(result[0], 10)) {
+                               if (parseInt(range_list[i], 10) === parseFloat(result[0])) {
                                        return (result[1][0] !== 'not');
                                }
                        }
@@ -541,7 +541,7 @@ function pluralRuleParser(rule, number) {
                var result = sequence([whitespace, _and_, whitespace, relation]);
 
                if (result !== null) {
-                       debug(' -- passed andTail' + result);
+                       debug(' -- passed andTail', result);
 
                        return result[3];
                }
@@ -556,7 +556,7 @@ function pluralRuleParser(rule, number) {
                var result = sequence([whitespace, _or_, whitespace, and]);
 
                if (result !== null) {
-                       debug(' -- passed orTail: ' + result[3]);
+                       debug(' -- passed orTail: ', result[3]);
 
                        return result[3];
                }
@@ -597,7 +597,7 @@ function pluralRuleParser(rule, number) {
        }
 
        if (pos !== rule.length) {
-               debug('Warning: Rule not parsed completely. Parser stopped at ' + rule.substr(0, pos) + ' for rule: ' + rule);
+               debug('Warning: Rule not parsed completely. Parser stopped at ', rule.substr(0, pos), ' for rule: ', rule);
        }
 
        return result;