optimize Identify (a bit)#1620
Merged
TheArcaneBrony merged 5 commits intospacebarchat:masterfrom Apr 6, 2026
Merged
Conversation
Member
|
checkToken doesnt have much that could be optimised, it does a whole 2 things:
|
src/gateway/opcodes/Identify.ts
Outdated
Comment on lines
+378
to
+408
| for (const c of memberGuildChannels) { | ||
| const arr = channelsByGuild.get(c.guild_id!); | ||
| if (arr) arr.push(c); | ||
| else channelsByGuild.set(c.guild_id!, [c]); | ||
| } | ||
| for (const e of memberGuildEmojis) { | ||
| const arr = emojisByGuild.get(e.guild_id!); | ||
| if (arr) arr.push(e); | ||
| else emojisByGuild.set(e.guild_id!, [e]); | ||
| } | ||
| for (const r of memberGuildRoles) { | ||
| const arr = rolesByGuild.get(r.guild_id!); | ||
| if (arr) arr.push(r); | ||
| else rolesByGuild.set(r.guild_id!, [r]); | ||
| } | ||
| for (const s of memberGuildStickers) { | ||
| const arr = stickersByGuild.get(s.guild_id!); | ||
| if (arr) arr.push(s); | ||
| else stickersByGuild.set(s.guild_id!, [s]); | ||
| } | ||
| for (const v of memberGuildVoiceStates) { | ||
| const arr = voiceStatesByGuild.get(v.guild_id!); | ||
| if (arr) arr.push(v); | ||
| else voiceStatesByGuild.set(v.guild_id!, [v]); | ||
| } | ||
| for (const t of allThreads) { | ||
| const arr = threadsByGuild.get(t.guild_id!); | ||
| if (arr) arr.push(t); | ||
| else threadsByGuild.set(t.guild_id!, [t]); | ||
| } | ||
|
|
Member
There was a problem hiding this comment.
also, we have an arrayGroupBy function for this :)
Contributor
Author
There was a problem hiding this comment.
Me happy when arrayGroupBy
src/util/util/ElapsedTime.ts
Outdated
| add(other: ElapsedTime): ElapsedTime { | ||
| return new ElapsedTime(this.timeNanos + other.totalNanoseconds); | ||
| } | ||
|
|
Member
There was a problem hiding this comment.
this class is supposed to be read-only :)
Contributor
Author
|
I will make a test just in case |
Contributor
Author
|
Seems to still work fine |
Member
|
will merge, worst case i revert i guess |
This file contains hidden or 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
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.
I'll write a proper description tomorrow
I plan to look into checkToken and userQuery too