-
-
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
refactor(SnowflakeUtil): clean up utils and improve perf #7036
Merged
iCrawl
merged 2 commits into
discordjs:main
from
kyranet:refactor/faster-snowflake-util
Nov 29, 2021
Merged
refactor(SnowflakeUtil): clean up utils and improve perf #7036
iCrawl
merged 2 commits into
discordjs:main
from
kyranet:refactor/faster-snowflake-util
Nov 29, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vladfrangu
approved these changes
Nov 25, 2021
This comment has been minimized.
This comment has been minimized.
SpaceEEC
approved these changes
Nov 27, 2021
iCrawl
approved these changes
Nov 29, 2021
Koyamie
added a commit
to Koyamie/discord.js
that referenced
this pull request
Dec 2, 2021
commit 01f8d1b Author: Jiralite <[email protected]> Date: Thu Dec 2 13:29:54 2021 +0000 types(Interaction): Narrow `memberPermissions` (discordjs#7054) commit 5fcda73 Author: That_Guy977 <[email protected]> Date: Thu Dec 2 20:29:21 2021 +0700 fix(GuildChannel): default to `this.rawPosition` in `clone()` (discordjs#7057) commit 552d89f Author: Rodry <[email protected]> Date: Wed Dec 1 11:40:49 2021 +0000 feat(Guild): add premiumProgressbarEnabled (discordjs#6887) Co-authored-by: Vlad Frangu <[email protected]> commit b183a8e Author: Rodry <[email protected]> Date: Wed Dec 1 11:33:28 2021 +0000 docs(Invite): add info blocks for missing props (discordjs#7014) commit da86bd4 Author: Suneet Tipirneni <[email protected]> Date: Wed Dec 1 06:33:11 2021 -0500 fix: Interaction channel type should be `GuildTextBasedChannels` when in guild (discordjs#6998) commit c07207f Author: That_Guy977 <[email protected]> Date: Wed Dec 1 18:32:13 2021 +0700 fix(Util): fix sorting for GuildChannels (discordjs#7002) commit 4fe063f Author: GrapeColor <[email protected]> Date: Wed Dec 1 20:31:37 2021 +0900 feat: add `UserContextMenuInteraction` and `MessageContextMenuInteraction` (discordjs#7003) Co-authored-by: Rodry <[email protected]> Co-authored-by: Suneet Tipirneni <[email protected]> Co-authored-by: Vlad Frangu <[email protected]> Co-authored-by: GrapeColor <[email protected]> commit a39d8c4 Author: Suneet Tipirneni <[email protected]> Date: Wed Dec 1 06:28:22 2021 -0500 Revert "types(ApplicationCommandManager): Deprecate old `*Data` type …usages and allow camel cased dapi types to be used (discordjs#7052) commit 85e6812 Author: Jiralite <[email protected]> Date: Wed Dec 1 11:27:24 2021 +0000 docs(MessageReference): Fix static link (discordjs#7041) commit e305156 Author: Suneet Tipirneni <[email protected]> Date: Mon Nov 29 13:32:26 2021 -0500 chore: bump deps (discordjs#7048) commit 374f970 Author: Antonio Román <[email protected]> Date: Mon Nov 29 11:20:52 2021 +0100 chore: add myself as contributor in package.json (discordjs#7037) commit e59fac3 Author: Antonio Román <[email protected]> Date: Mon Nov 29 11:20:18 2021 +0100 refactor(SnowflakeUtil): clean up utils and improve perf (discordjs#7036) commit fd63139 Author: Antonio Román <[email protected]> Date: Mon Nov 29 11:19:32 2021 +0100 fix(MessageManager): do not use `client.emojis` (discordjs#7039) commit 0193efa Author: Antonio Román <[email protected]> Date: Mon Nov 29 11:19:21 2021 +0100 fix(ActionsManager): revert to manual requires (discordjs#7034) commit fabd343 Author: Antonio Román <[email protected]> Date: Mon Nov 29 11:18:41 2021 +0100 fix(MessagePayload): prevent spread of `undefined` (discordjs#7029) commit 2c91c48 Author: Suneet Tipirneni <[email protected]> Date: Mon Nov 29 05:17:57 2021 -0500 types(ApplicationCommandManager): Deprecate old `*Data` type usages and allow camel cased dapi types to be used (discordjs#6959)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please describe the changes this PR makes and why it should be merged:
Removes two unneeded private utilities (
Util.binaryToId
andUtil.idToBinary
) and increases the performance ofSnowflakeUtil.generate
andSnowflakeUtil.deconstruct
:deconstruct
deconstruct
generate
generate
10000
100000
1000000
SnowflakeUtil.deconstruct
is used in a total of 17 places:ApplicationCommand
,BaseGuild
,Channel
,Emoji
,GuildAuditLogs
,GuildPreview
,Interaction
,Message
,Role
,StageInstance
,Sticker
,StickerPack
,Team
,User
,Webhook
,Application
, andTextBasedChannel
, to get the timestamp from a snowflake ID given by Discord.Snowflake.generate
is used to generate the nonce inGuildMemberManager
.I could also make
SnowflakeUtil.getTimestamp(Snowflake)
to offer a +4 times faster alternative toSnowflakeUtil.deconstruct(Snowflake).timestamp
, skipping allocations and a lot of overhead.Status and versioning classification: