-
Notifications
You must be signed in to change notification settings - Fork 30k
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
test: Change declaration by var to let. #9711
Conversation
@@ -249,8 +249,8 @@ function writeToFill(string, offset, end, encoding) { | |||
|
|||
// Correction for UCS2 operations. | |||
if (os.endianness() === 'BE' && encoding === 'ucs2') { | |||
for (var i = 0; i < buf2.length; i += 2) { | |||
var tmp = buf2[i]; | |||
for (let i = 0; i < buf2.length; i += 2) { |
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.
Its against no-let-in-for-loop rule.
CC: @Trott
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.
Reference: #9045
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.
That rule was created to help people avoid the whole "using let
in for
loops is slow" performance problem. I would avoid it. EDIT: Whoops, but that applies to lib
, not test
.
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.
It probably doesn't matter for tests though.
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.
Right. It's only enabled in the lib
directory.
for (var i = 0; i < buf2.length; i += 2) { | ||
var tmp = buf2[i]; | ||
for (let i = 0; i < buf2.length; i += 2) { | ||
let tmp = buf2[i]; |
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.
I think this can even be const
.
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.
I think so too.
so Fixed :)
Your author name in this commit is given as “ubansi”. Is that intended or do you prefer to be listed (changelog, git log, AUTHORS file) with some other name? People typically prefer their full name, but ultimately it’s up to you. |
How about changing the two instances of |
@addaleax It's ok. Thank you. |
@Trott I tried it after your advice.
this code is faild in win10.
I stop it this time. |
@Trott It was just a Lint error. |
5c17df5
to
6355c2c
Compare
I narrowed the scope of local variables in "for" on test.
Because "tmp" is never changed.
@ubansi can you rebase please CI: https://ci.nodejs.org/job/node-test-pull-request/5895/console |
@italoacasas I'm pretty sure rebasing this will make it a no-op. There's no |
I'm going to close this because I don't think it's applicable to the file anymore. If I'm mistaken, please comment here and/or re-open. Thanks! |
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
none
Description of change
I narrowed the scope of local variables in
for
on test-buffer-fill.js.Since
i
andtmp
are not used outside offor
, they do not have to bevar
declarations.