-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix min() and max() crashing on large arrays #6129
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
Conversation
…ses stack error, replaced with simple for loop
|
🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. And be sure to add yourself to the list of contributors on the readme page! |
|
@all-contributors please add @pmarsh-scottlogic for THING(S) |
|
I couldn't determine any contributions to add, did you specify any contributions? |
|
https://github.com/all-contributors please add @pmarsh-scottlogic for code |
|
@all-contributors please add @pmarsh-scottlogic for code |
|
I've put up a pull request to add @pmarsh-scottlogic! 🎉 |
|
Looks good. Thanks! |
|
Nice work @pmarsh-scottlogic! |
|
Thanks @pmarsh-scottlogic! |
Resolves #6101
Changes:
The previous implementation of the
max()andmin()methods usedFunction.prototype.apply(), which would have a stack error on arrays of length more than ~120000. On the back of a discussion under the issue, I benchmarked a few alternative implementations and we settled with a simple for loop, which is one of the fastest if not the fastest implementation across all array sizes.PR Checklist
npm run lintpassesno doc or unit test changes given that the functionality has not really been changed