-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
for ... of replacing for(;;) in library networking code? #31024
Comments
The fact multiple files were updated with a comment saying |
What was the point of this change in the first place? How did it make Node better? Its a waste of time and a performance step back regardless of how small. |
Arguably, it makes the code more readable and thus maintainable. Since it's in a place where there is no measurable performance impact, readability/maintainability can take precedence. Additionally, there's something to be said for favoring idiomatic code. There are, of course, counterarguments. Perhaps the For me, the most convincing argument against it is probably that cosmetic code changes entail risk of introducing bugs and should have a compelling reason for being introduced in These things are tradeoffs and reasonable people can make different decisions about them. (Personally, I had a mild/minuscule preference for not making the change, but with previous approvals, I'd rather approve-and-land-and-move-on than get mired in a discussion about the merits etc. The cost/benefit of the discussion isn't worth it. And if it's more readable for other folks, that's reason enough.) |
(Also, if the concern is just this one file, a PR changing it back to |
I would like to add to the performance part: Loop performance is not an issue anymore as of Node.js version >= 10.x. No matter if it's But even if there is a tiny performance difference, it would not show up as a real downside for applications, since the actual code running would make up for most of the run time of the loop. Idiomatic code should be more important than 0.01% performance improvement. Actual performance gains are almost always possible by changing the algorithm in some way - not by using different for loops! |
Closing. If any collaborator would like to keep this open, please feel free to do so. |
Why was [https://github.com//pull/30958] approved and released in 13.5? It has no real justification and actually has a performance impact. for(;;) will always be the fasted loop.
The text was updated successfully, but these errors were encountered: