Skip to content

Commit f0cf29c

Browse files
committed
Remove unnecessary usage of jstoi_q. NFC
In most use cases we can just use `Number` instead. Split out from #23789.
1 parent 8686d5b commit f0cf29c

File tree

6 files changed

+23
-24
lines changed

6 files changed

+23
-24
lines changed

src/lib/libatomic.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ addToLibrary({
2222
// https://github.com/tc39/proposal-atomics-wait-async/blob/master/PROPOSAL.md
2323
// This polyfill performs polling with setTimeout() to observe a change in the
2424
// target memory location.
25-
$polyfillWaitAsync__postset: `if (!Atomics.waitAsync || (typeof navigator != 'undefined' && navigator.userAgent && jstoi_q((navigator.userAgent.match(/Chrom(e|ium)\\/([0-9]+)\\./)||[])[2]) < 91)) {
25+
$polyfillWaitAsync__postset: `if (!Atomics.waitAsync || (typeof navigator != 'undefined' && navigator.userAgent && Number((navigator.userAgent.match(/Chrom(e|ium)\\/([0-9]+)\\./)||[])[2]) < 91)) {
2626
let __Atomics_waitAsyncAddresses = [/*[i32a, index, value, maxWaitMilliseconds, promiseResolve]*/];
2727
function __Atomics_pollWaitAsyncAddresses() {
2828
let now = performance.now();
@@ -60,7 +60,6 @@ addToLibrary({
6060
return { async: true, value: promise };
6161
};
6262
}`,
63-
$polyfillWaitAsync__deps: ['$jstoi_q'],
6463
#endif
6564

6665
$polyfillWaitAsync__internal: true,

src/lib/libc_preprocessor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ addToLibrary({
3535
// Runs C preprocessor algorithm on the given string 'code'.
3636
// Supported preprocessor directives: #if, #ifdef, #ifndef, #else, #elif, #endif, #define and #undef.
3737
// predefs: Specifies a dictionary of { 'key1': function(arg0, arg1) {...}, 'key2': ... } of predefined preprocessing variables
38-
$preprocess_c_code__deps: ['$jstoi_q', '$find_closing_parens_index'],
38+
$preprocess_c_code__deps: ['$find_closing_parens_index'],
3939
$preprocess_c_code: function(code, defs = {}) {
4040
var i = 0, // iterator over the input string
4141
len = code.length, // cache input length
@@ -207,7 +207,7 @@ addToLibrary({
207207
if (tokens[i] == ')') throw 'Parsing failure, mismatched parentheses in parsing!' + tokens.toString();
208208
assert(operatorAndPriority == -1);
209209
#endif
210-
var num = jstoi_q(tokens[i]);
210+
var num = Number(tokens[i]);
211211
return [function() { return num; }]
212212
})(tokens);
213213
}

src/lib/libcore.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ addToLibrary({
647647
},
648648
$inetNtop4: (addr) =>
649649
(addr & 0xff) + '.' + ((addr >> 8) & 0xff) + '.' + ((addr >> 16) & 0xff) + '.' + ((addr >> 24) & 0xff),
650-
$inetPton6__deps: ['htons', '$jstoi_q'],
650+
$inetPton6__deps: ['htons'],
651651
$inetPton6: (str) => {
652652
var words;
653653
var w, offset, z, i;
@@ -671,8 +671,8 @@ addToLibrary({
671671
// parse IPv4 embedded stress
672672
str = str.replace(new RegExp('[.]', 'g'), ":");
673673
words = str.split(":");
674-
words[words.length-4] = jstoi_q(words[words.length-4]) + jstoi_q(words[words.length-3])*256;
675-
words[words.length-3] = jstoi_q(words[words.length-2]) + jstoi_q(words[words.length-1])*256;
674+
words[words.length-4] = Number(words[words.length-4]) + Number(words[words.length-3])*256;
675+
words[words.length-3] = Number(words[words.length-2]) + Number(words[words.length-1])*256;
676676
words = words.slice(0, words.length-2);
677677
} else {
678678
words = str.split(":");

src/lib/libhtml5.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ var LibraryHTML5 = {
13071307
$currentFullscreenStrategy: {},
13081308
$restoreOldWindowedStyle: null,
13091309

1310-
$softFullscreenResizeWebGLRenderTarget__deps: ['$JSEvents', '$setLetterbox', '$currentFullscreenStrategy', '$getCanvasElementSize', '$setCanvasElementSize', '$jstoi_q'],
1310+
$softFullscreenResizeWebGLRenderTarget__deps: ['$JSEvents', '$setLetterbox', '$currentFullscreenStrategy', '$getCanvasElementSize', '$setCanvasElementSize'],
13111311
$softFullscreenResizeWebGLRenderTarget: () => {
13121312
var dpr = devicePixelRatio;
13131313
var inHiDPIFullscreenMode = currentFullscreenStrategy.canvasResolutionScaleMode == {{{ cDefs.EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_HIDEF }}};
@@ -1347,8 +1347,8 @@ var LibraryHTML5 = {
13471347
}
13481348

13491349
if (inCenteredWithoutScalingFullscreenMode) {
1350-
var t = (innerHeight - jstoi_q(canvas.style.height)) / 2;
1351-
var b = (innerWidth - jstoi_q(canvas.style.width)) / 2;
1350+
var t = (innerHeight - Number(canvas.style.height)) / 2;
1351+
var b = (innerWidth - Number(canvas.style.width)) / 2;
13521352
setLetterbox(canvas, t, b);
13531353
} else {
13541354
canvas.style.width = w + 'px';

src/lib/libtime.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ addToLibrary({
257257
},
258258

259259
strptime__deps: ['$isLeapYear', '$arraySum', '$addDays', '$MONTH_DAYS_REGULAR', '$MONTH_DAYS_LEAP',
260-
'$jstoi_q', '$intArrayFromString' ],
260+
'$intArrayFromString' ],
261261
strptime: (buf, format, tm) => {
262262
// char *strptime(const char *restrict buf, const char *restrict format, struct tm *restrict tm);
263263
// http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html
@@ -362,21 +362,21 @@ addToLibrary({
362362

363363
// seconds
364364
if ((value=getMatch('S'))) {
365-
date.sec = jstoi_q(value);
365+
date.sec = Number(value);
366366
}
367367

368368
// minutes
369369
if ((value=getMatch('M'))) {
370-
date.min = jstoi_q(value);
370+
date.min = Number(value);
371371
}
372372

373373
// hours
374374
if ((value=getMatch('H'))) {
375375
// 24h clock
376-
date.hour = jstoi_q(value);
376+
date.hour = Number(value);
377377
} else if ((value = getMatch('I'))) {
378378
// AM/PM clock
379-
var hour = jstoi_q(value);
379+
var hour = Number(value);
380380
if ((value=getMatch('p'))) {
381381
hour += value.toUpperCase()[0] === 'P' ? 12 : 0;
382382
}
@@ -386,13 +386,13 @@ addToLibrary({
386386
// year
387387
if ((value=getMatch('Y'))) {
388388
// parse from four-digit year
389-
date.year = jstoi_q(value);
389+
date.year = Number(value);
390390
} else if ((value=getMatch('y'))) {
391391
// parse from two-digit year...
392-
var year = jstoi_q(value);
392+
var year = Number(value);
393393
if ((value=getMatch('C'))) {
394394
// ...and century
395-
year += jstoi_q(value)*100;
395+
year += Number(value)*100;
396396
} else {
397397
// ...and rule-of-thumb
398398
year += year<69 ? 2000 : 1900;
@@ -403,7 +403,7 @@ addToLibrary({
403403
// month
404404
if ((value=getMatch('m'))) {
405405
// parse from month number
406-
date.month = jstoi_q(value)-1;
406+
date.month = Number(value)-1;
407407
} else if ((value=getMatch('b'))) {
408408
// parse from month name
409409
date.month = MONTH_NUMBERS[value.substring(0,3).toUpperCase()] || 0;
@@ -413,10 +413,10 @@ addToLibrary({
413413
// day
414414
if ((value=getMatch('d'))) {
415415
// get day of month directly
416-
date.day = jstoi_q(value);
416+
date.day = Number(value);
417417
} else if ((value=getMatch('j'))) {
418418
// get day of month from day of year ...
419-
var day = jstoi_q(value);
419+
var day = Number(value);
420420
var leapYear = isLeapYear(date.year);
421421
for (var month=0; month<12; ++month) {
422422
var daysUntilMonth = arraySum(leapYear ? MONTH_DAYS_LEAP : MONTH_DAYS_REGULAR, month-1);
@@ -432,7 +432,7 @@ addToLibrary({
432432
// Week number of the year (Sunday as the first day of the week) as a decimal number [00,53].
433433
// All days in a new year preceding the first Sunday are considered to be in week 0.
434434
var weekDayNumber = DAY_NUMBERS_SUN_FIRST[weekDay];
435-
var weekNumber = jstoi_q(value);
435+
var weekNumber = Number(value);
436436

437437
// January 1st
438438
var janFirst = new Date(date.year, 0, 1);
@@ -451,7 +451,7 @@ addToLibrary({
451451
// Week number of the year (Monday as the first day of the week) as a decimal number [00,53].
452452
// All days in a new year preceding the first Monday are considered to be in week 0.
453453
var weekDayNumber = DAY_NUMBERS_MON_FIRST[weekDay];
454-
var weekNumber = jstoi_q(value);
454+
var weekNumber = Number(value);
455455

456456
// January 1st
457457
var janFirst = new Date(date.year, 0, 1);

src/lib/libwebgl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3205,7 +3205,7 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
32053205
#if GL_DEBUG
32063206
console.dir(match);
32073207
#endif
3208-
explicitUniformLocations[match[5]] = jstoi_q(match[1]);
3208+
explicitUniformLocations[match[5]] = Number(match[1]);
32093209
#if GL_TRACK_ERRORS
32103210
if (!(explicitUniformLocations[match[5]] >= 0 && explicitUniformLocations[match[5]] < 1048576)) {
32113211
err(`Specified an out of range layout(location=x) directive "${explicitUniformLocations[match[5]]}"! (${match[0]})`);

0 commit comments

Comments
 (0)