Skip to content

Commit

Permalink
[MERGE #3724 @dilijev] Revert non-optimal pattern in Intl.js
Browse files Browse the repository at this point in the history
Merge pull request #3724 from dilijev:intl-revert
  • Loading branch information
dilijev committed Sep 14, 2017
2 parents b7e2382 + 0b2b918 commit d19bf32
Show file tree
Hide file tree
Showing 5 changed files with 12,871 additions and 12,748 deletions.
24 changes: 18 additions & 6 deletions lib/Runtime/Library/InJavascript/Intl.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,8 +758,12 @@

function Collator() {
// The function should have length of 0, hence we are getting arguments this way.
let locales = arguments[0];
let options = arguments[1];
// While it's true that we could just do e.g. arguments[0] and get undefined if it is not present,
// that makes assumptions that the JIT must check. This pattern is marginally more efficient.
var locales = undefined;
var options = undefined;
if (arguments.length >= 1) locales = arguments[0];
if (arguments.length >= 2) options = arguments[1];

if (this === Intl || this === undefined) {
return new Collator(locales, options);
Expand Down Expand Up @@ -999,8 +1003,12 @@
if (InitType === 'Intl') {
function NumberFormat() {
// The function should have length of 0, hence we are getting arguments this way.
let locales = arguments[0];
let options = arguments[1];
// While it's true that we could just do e.g. arguments[0] and get undefined if it is not present,
// that makes assumptions that the JIT must check. This pattern is marginally more efficient.
var locales = undefined;
var options = undefined;
if (arguments.length >= 1) locales = arguments[0];
if (arguments.length >= 2) options = arguments[1];

if (this === Intl || this === undefined) {
return new NumberFormat(locales, options);
Expand Down Expand Up @@ -1497,8 +1505,12 @@
if (InitType === 'Intl') {
function DateTimeFormat() {
// The function should have length of 0, hence we are getting arguments this way.
let locales = arguments[0];
let options = arguments[1];
// While it's true that we could just do e.g. arguments[0] and get undefined if it is not present,
// that makes assumptions that the JIT must check. This pattern is marginally more efficient.
var locales = undefined;
var options = undefined;
if (arguments.length >= 1) locales = arguments[0];
if (arguments.length >= 2) options = arguments[1];

if (this === Intl || this === undefined) {
return new DateTimeFormat(locales, options);
Expand Down
Loading

0 comments on commit d19bf32

Please sign in to comment.