From af19e7b270d1668eab9be92998b55ab64a721a8b Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 4 Oct 2018 22:17:30 +0100 Subject: [PATCH] resources: Update CLDRPluralRuleParser to v1.3.2-pre 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 | 4 ++-- .../CLDRPluralRuleParser.js | 22 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/maintenance/resources/foreign-resources.yaml b/maintenance/resources/foreign-resources.yaml index c610b3c90a..70068dcf3b 100644 --- a/maintenance/resources/foreign-resources.yaml +++ b/maintenance/resources/foreign-resources.yaml @@ -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 diff --git a/resources/lib/CLDRPluralRuleParser/CLDRPluralRuleParser.js b/resources/lib/CLDRPluralRuleParser/CLDRPluralRuleParser.js index 1491e3d70d..73268d443e 100644 --- a/resources/lib/CLDRPluralRuleParser/CLDRPluralRuleParser.js +++ b/resources/lib/CLDRPluralRuleParser/CLDRPluralRuleParser.js @@ -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 * @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; -- 2.20.1