-
-
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): Use iterable and exit early if found #9490
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
Thanks! Good catch Co-authored-by: Aura Román <kyradiscord@gmail.com>
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.
Otherwise LGTM.
Couldn't this also be applied to discord.js/packages/discord.js/src/structures/GuildChannel.js Lines 147 to 150 in a9f2bff
|
Yeah definitely could. In my own use case I had a similar issue as the open issue on the repo, but it could definitely have the same type of problems if someone was looping through the channels |
Please describe the changes this PR makes and why it should be merged:
This improves performance by not copying the role sorted collection into an array, which is how the spread syntax treats it. This should help with both memory and CPU since it creates a copy of the array. This does not fully address #3925 but would help mitigate some performance issues related to access the position property frequently.
Some profiling:
Status and versioning classification:
Patch