-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
perf(Role): linear speed position getter #9493
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Can you make the same for channels? |
Yes, in a follow-up PR, I wanted to push this one first to get reviews in case the code can be improved any further. |
Idk if using for loop wont be a little bit faster, as it will be not calling the function everytime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐎
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://discord-js-guide-git-fork-kyranet-perf-rolefas-cb6b68-discordjs.vercel.app/guide/home/introduction |
Please describe the changes this PR makes and why it should be merged:
Alternative to #9490, fixes #3925.
Basically skips the
sorted
call, which is an algorithm with an O(n * log(n)) cost, as well as the indexOf, which is a O(n) call. With this, not only it's not longer allocating a Collection nor an Array (making the only allocation be the iterator used in reduce), but the performance also goes down to a single O(n).🤖 Generated by Copilot at 8b28bc4
Status and versioning classification: