-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Remove unnecessary usage of jstoi_q. NFC #23791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -362,21 +362,21 @@ addToLibrary({ | |||
|
|||
// seconds | |||
if ((value=getMatch('S'))) { | |||
date.sec = jstoi_q(value); | |||
date.sec = Number(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code above is fairly complex - how can I see that this is a pure number without a prefix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getMatch
function returns that result of the regex's above.
You can see that we only call Number
on the following matches: S, M, H, I, Y, y, C, m, d, j, U, W.
You can look at the above table of regexes and see that each of them only ever match numbers.
We also have pretty extensive testing for strftime I believe.
@@ -3205,7 +3205,7 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; | |||
#if GL_DEBUG | |||
console.dir(match); | |||
#endif | |||
explicitUniformLocations[match[5]] = jstoi_q(match[1]); | |||
explicitUniformLocations[match[5]] = Number(match[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, is the 5th capture not \w+
, which accepts more than digits? Am I computing that wrong, or perhaps does the GL API guarantee an integer here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using the first capture here aren't we? That looks like (-?\d+)
to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, somehow my eye read the match[5]
on the left...
f0cf29c
to
8e04e4a
Compare
In most use cases we can just use `Number` instead. Split out from emscripten-core#23789.
8e04e4a
to
542b6b2
Compare
The
jstoi_q
was introduced in #10457 because of issues with usingparseInt
directly and closure compiler. However, in many cases its simpler to just useNumber
. See google/closure-compiler#3230Split out from #23789.