-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
lib: use arrow functions instead of bind #3622
Conversation
I don't think you should touch anything in |
Yes, please be sure not to touch anything in |
@JungMinu instead of making a new PR you can just amend you changes (via |
@JungMinu actually; even more specific: please only do files in |
Looks like the file permissions for the files in Also, have you done any benchmarking to show before and after these changes? Looking at the diff, I'm not sure that these changes actually affect any hot code paths. |
Except for the last sentence, the PR text appears to be copied from https://www.nczonline.net/blog/2013/09/10/understanding-ecmascript-6-arrow-functions/. If you want to use someone else's text verbatim, please remember to cite it. |
I'd be keen to see that benchmark as well before landing this. |
The win here, at least the way I see it, is in readability by getting rid of all the As noted by @mscdex, none of this looks like it's in a hot path and so I very much doubt any of this will result in a measurable performance boost. Benchmark proving otherwise welcome, but it seems like the benefit here is a the readability/maintainability gain. |
IMHO as far as readability goes, it's about the same, maybe worse (but that would be more of a general ES6 problem). |
I guess where I was heading was that if this goes in with "faster" as the commit message it should be properly warranted. Style "fixes" is another category. |
|
Minus the file permission changes, LGTM. As @mscdex mentioned, it's not an improvement in readability, but that's not what we're going after. In these specific locations there's nothing hot so won't notice a performance gain, but might as well make the change where it makes sense. |
@JungMinu I'm not sure you caught every case of Also how did you edit the files? I'm not sure what would have caused those mode changes. |
Oh, maybe those mode changes were from previously changing those files.. |
ok, that search from my windows machine wasn't correct, but using Atom Editor I find 28 results across 7 files for Looks like there's nothing in |
Abandoning PRs and refiling them again is kind of annoying because it loses the discussion and the review history (of which there was quite a bit, it looks like.) Can I suggest you do a rebase, fix up the issues and force-push to your existing branch? |
If your implicit question is 'how?', check the documentation for |
Presumably your editor did something to those files? When in doubt, use vim. |
Hmm, A consideration we should make: If there is a If it were possible Ideally we'd have We could write it as @trevnorris Does that sound about right? I think we need to be careful for now. Rest params come in v8 4.7, so we could just have this target master once that lands, even though it'l be 6 months until it ships then. |
There is no rush on this change, right? |
@cjihrig Correct. (That being said, it would be nice to have subset in v5 if possible.) |
@Fishrock123 Currently rest parameters are even less optimized than |
* http: - A new status code was added: 451 - "Unavailable For Legal Reasons" (Max Barinov) nodejs#4377 - Idle sockets that have been kept alive now handle errors (José F. Romaniello) nodejs#4482 * This release also includes several minor performance improvements: - assert: deepEqual is now speedier when comparing TypedArrays (Claudio Rodriguez) nodejs#4330 - lib: Use arrow functions instead of bind where possible (Minwoo Jung) nodejs#3622 - node: Improved accessor perf of process.env (Trevor Norris) nodejs#3780 - node: Improved performance of process.hrtime() (Trevor Norris) nodejs#3780, (Evan Lucas) nodejs#4484 - node: Improved GetActiveHandles performance (Trevor Norris) nodejs#3780 - util: Use faster iteration in util.format() (Jackson Tian) nodejs#3964 PR-URL: nodejs#4547
* http: - A new status code was added: 451 - "Unavailable For Legal Reasons" (Max Barinov) nodejs#4377 - Idle sockets that have been kept alive now handle errors (José F. Romaniello) nodejs#4482 * This release also includes several minor performance improvements: - assert: deepEqual is now speedier when comparing TypedArrays (Claudio Rodriguez) nodejs#4330 - lib: Use arrow functions instead of bind where possible (Minwoo Jung) nodejs#3622 - node: Improved accessor perf of process.env (Trevor Norris) nodejs#3780 - node: Improved performance of process.hrtime() (Trevor Norris) nodejs#3780, (Evan Lucas) nodejs#4484 - node: Improved GetActiveHandles performance (Trevor Norris) nodejs#3780 - util: Use faster iteration in util.format() (Jackson Tian) nodejs#3964 Refs: nodejs#4547 PR-URL: nodejs#4623 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
use `arrow functions` instead of `bind(this)` in order to improve performance through optimizations. PR-URL: #3622 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Myles Borins <[email protected]>
Just putting a note here that this commit has still not landed in v5.4.x |
Some backstory on that:
|
use `arrow functions` instead of `bind(this)` in order to improve performance through optimizations. PR-URL: #3622 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Myles Borins <[email protected]>
Notable changes: * events: make sure console functions exist (Dave) #4479 * fs: add autoClose option to fs.createWriteStream (Saquib) #3679 * http: improves expect header handling (Daniel Sellers) #4501 * node: allow preload modules with -i (Evan Lucas) #4696 * v8,src: expose statistics about heap spaces (`v8.getHeapSpaceStatistics()`) (Ben Ripkens) #4463 * Minor performance improvements: - lib: Use arrow functions instead of bind where possible (Minwoo Jung) #3622 - module: cache stat() results more aggressively (Ben Noordhuis) #4575 - querystring: improve parse() performance (Brian White) #4675 PR-URL: #4742
Notable changes: * events: make sure console functions exist (Dave) #4479 * fs: add autoClose option to fs.createWriteStream (Saquib) #3679 * http: improves expect header handling (Daniel Sellers) #4501 * node: allow preload modules with -i (Evan Lucas) #4696 * v8,src: expose statistics about heap spaces (`v8.getHeapSpaceStatistics()`) (Ben Ripkens) #4463 * Minor performance improvements: - lib: Use arrow functions instead of bind where possible (Minwoo Jung) #3622 - module: cache stat() results more aggressively (Ben Noordhuis) #4575 - querystring: improve parse() performance (Brian White) #4675 PR-URL: #4742
Regarding benchmarks, I'm not sure if the requests were for bind to arrow functions performance in general, or their performance when applied to node's codebase via this PR. For the former, for those interested, there is https://github.com/bevry/esnext-benchmarks which compares performance with several esnext features with the es2015 and other counterparts. Perhaps it will be useful for some readers. If it was the latter, can't help there. |
use `arrow functions` instead of `bind(this)` in order to improve performance through optimizations. PR-URL: #3622 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Myles Borins <[email protected]>
use `arrow functions` instead of `bind(this)` in order to improve performance through optimizations. PR-URL: #3622 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Myles Borins <[email protected]>
use `arrow functions` instead of `bind(this)` in order to improve performance through optimizations. PR-URL: #3622 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Myles Borins <[email protected]>
use `arrow functions` instead of `bind(this)` in order to improve performance through optimizations. PR-URL: nodejs#3622 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Myles Borins <[email protected]>
* http: - A new status code was added: 451 - "Unavailable For Legal Reasons" (Max Barinov) nodejs#4377 - Idle sockets that have been kept alive now handle errors (José F. Romaniello) nodejs#4482 * This release also includes several minor performance improvements: - assert: deepEqual is now speedier when comparing TypedArrays (Claudio Rodriguez) nodejs#4330 - lib: Use arrow functions instead of bind where possible (Minwoo Jung) nodejs#3622 - node: Improved accessor perf of process.env (Trevor Norris) nodejs#3780 - node: Improved performance of process.hrtime() (Trevor Norris) nodejs#3780, (Evan Lucas) nodejs#4484 - node: Improved GetActiveHandles performance (Trevor Norris) nodejs#3780 - util: Use faster iteration in util.format() (Jackson Tian) nodejs#3964 Refs: nodejs#4547 PR-URL: nodejs#4623 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Notable changes: * events: make sure console functions exist (Dave) nodejs#4479 * fs: add autoClose option to fs.createWriteStream (Saquib) nodejs#3679 * http: improves expect header handling (Daniel Sellers) nodejs#4501 * node: allow preload modules with -i (Evan Lucas) nodejs#4696 * v8,src: expose statistics about heap spaces (`v8.getHeapSpaceStatistics()`) (Ben Ripkens) nodejs#4463 * Minor performance improvements: - lib: Use arrow functions instead of bind where possible (Minwoo Jung) nodejs#3622 - module: cache stat() results more aggressively (Ben Noordhuis) nodejs#4575 - querystring: improve parse() performance (Brian White) nodejs#4675 PR-URL: nodejs#4742
use
arrow functions
instead ofbind(this)
in order to improveperformance through optimizations.