Skip to content
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

os: avoid unnecessary usage of var #42563

Merged
merged 1 commit into from
Apr 3, 2022

Conversation

VoltrexKeyva
Copy link
Member

The var keyword is known to be problematic and is not needed here,
so better to use the let keyword for variable declarations.

The `var` keyword is known to be problematic and is not needed here,
so better to use the `let` keyword for variable declarations.
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. os Issues and PRs related to the os subsystem. labels Apr 1, 2022
Copy link
Member

@tniessen tniessen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised to see we still have some var declarations (assuming there are no performance edge cases here, but I think V8 fixed those years ago).

@RaisinTen
Copy link
Contributor

RaisinTen commented Apr 1, 2022

Running the os benchmarks to be sure because we have a benchmark test for

networkInterfaces();

which we are touching in this PR and we still have comments like
// Using var here instead of let because "for (var ...)" is faster than let.
// Refs: https://github.com/nodejs/node/pull/30380#issuecomment-552948364

https://ci.nodejs.org/job/benchmark-node-micro-benchmarks/1115/

                                confidence improvement accuracy (*)   (**)  (***)
os/cpus.js n=30000                              0.00 %       ±0.68% ±0.91% ±1.18%
os/loadavg.js n=5000000                        -0.40 %       ±1.17% ±1.55% ±2.02%
os/networkInterfaces.js n=10000                -2.51 %       ±4.75% ±6.32% ±8.23%

I guess, we can replace all the vars with let/consts.

Copy link
Contributor

@RaisinTen RaisinTen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@marsonya marsonya added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Apr 1, 2022
@VoltrexKeyva VoltrexKeyva added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 2, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 2, 2022
@nodejs-github-bot
Copy link
Collaborator

@RaisinTen RaisinTen added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 2, 2022
@VoltrexKeyva VoltrexKeyva removed the needs-ci PRs that need a full CI run. label Apr 2, 2022
@Trott Trott added the needs-ci PRs that need a full CI run. label Apr 3, 2022
@Trott
Copy link
Member

Trott commented Apr 3, 2022

A bit of an aside, but I've re-added the needs-ci label.

It's perhaps a bit confusingly named, but the needs-ci label is there for the commit queue automation. It tells the automation that this is a PR that should land only if there is a passing Jenkins CI run. It's not a label letting other people know that we need a CI run. So it should generally not be manually removed (unless it was incorrectly placed on a PR in the first place.)

Refs: https://github.com/nodejs/node-core-utils/blob/919ec3b784a2589aa88a1b2629b98d57283555a4/lib/pr_checker.js#L431-L438

@Trott Trott added the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 3, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 3, 2022
@nodejs-github-bot nodejs-github-bot merged commit b5f0b49 into nodejs:master Apr 3, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in b5f0b49

@VoltrexKeyva VoltrexKeyva deleted the avoid-var branch April 3, 2022 16:34
juanarbol pushed a commit to juanarbol/node that referenced this pull request Apr 5, 2022
The `var` keyword is known to be problematic and is not needed here,
so better to use the `let` keyword for variable declarations.

PR-URL: nodejs#42563
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This was referenced Apr 5, 2022
juanarbol pushed a commit that referenced this pull request Apr 6, 2022
The `var` keyword is known to be problematic and is not needed here,
so better to use the `let` keyword for variable declarations.

PR-URL: #42563
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
xtx1130 pushed a commit to xtx1130/node that referenced this pull request Apr 25, 2022
The `var` keyword is known to be problematic and is not needed here,
so better to use the `let` keyword for variable declarations.

PR-URL: nodejs#42563
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
juanarbol pushed a commit that referenced this pull request May 31, 2022
The `var` keyword is known to be problematic and is not needed here,
so better to use the `let` keyword for variable declarations.

PR-URL: #42563
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
danielleadams pushed a commit that referenced this pull request Jun 27, 2022
The `var` keyword is known to be problematic and is not needed here,
so better to use the `let` keyword for variable declarations.

PR-URL: #42563
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Jul 11, 2022
The `var` keyword is known to be problematic and is not needed here,
so better to use the `let` keyword for variable declarations.

PR-URL: #42563
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Jul 31, 2022
The `var` keyword is known to be problematic and is not needed here,
so better to use the `let` keyword for variable declarations.

PR-URL: #42563
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
guangwong pushed a commit to noslate-project/node that referenced this pull request Oct 10, 2022
The `var` keyword is known to be problematic and is not needed here,
so better to use the `let` keyword for variable declarations.

PR-URL: nodejs/node#42563
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. needs-ci PRs that need a full CI run. os Issues and PRs related to the os subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants