-
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
Chore: Use arrow functions where possible (lexical this
).
#7414
Comments
This commit merits extra scrutiny. Refs nodejs#7414
It’s up to the one who creates the PR how they do it, but the commits will very likely be squashed together anyway. |
Extra scrutiny required for this change Refs nodejs#7414
@addaleax it's more so I can interactive rebase or cherry-pick should a specific commit need removing etc; just sort of a habit I got in to. |
@aubergine10 As said, it’s up to you. :) Tbqh, I’d like to hear or work out some kind of rule of thumb of which types of style-only changes are generally considered worthwhile. These kind of changes tend to generate a lot of noise, and while I see that something like #7378 can improve readability noticeably, I’m not sure that’s always the case. |
@addaleax Ultimately it will probably depend on whether there are any improvements in terms of performance, gc, RAM consumption, etc. I'm not skilled enough to determine whether there are any tangible benefits to replacing the |
I wouldn’t expect any significant performance difference, no. |
Based on the discussion yesterday I did some googling regarding performance of arrow functions and other ES6 features and found this: http://kpdecker.github.io/six-speed/ If those results are correct, it looks like ES6 features, in general, are currently offering very little benefit over their ES5 counterparts and in many cases result in notably worse performance. I noticed that the Node.js test scripts include some performance tests but I'm not sure how to extract that data and compare to data from the unmodified scripts... Would be interesting to see what the performance impact is of the current two batches of edits. Without a clear improvement in performance, I don't think there's any benefit to using arrow functions over the ES5 approach. Another interesting read on arrow functions: https://blog.getify.com/arrow-this/ |
Arrow functions are great for replacing |
Heh - so, after submitting a PR for Curious that certain arrow operations are slower than ES5 (semi-)equivalents. Without any real understanding of how V8 implements these language features it seems arrow functions should typically perform faster because the runtime doesn't need to allocate a new |
Closing. This has been happening incrementally |
Following on from #7295, I've spotted similar pattern in many other files:
In most scenarios, this pattern can be replaced with an arrow function, allowing removal of 'self' var:
I'd like to use this issue ticket as a hub for several commits/PRs relating to this (one changed file per PR, although there may be several commits in the PR - one for each arrow function implemented in the file).
The text was updated successfully, but these errors were encountered: