You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: quick wins on hot paths without behavior changes
- Random.id/secret (server): generate all randomness with a single
crypto.randomBytes call instead of one per character (~15x faster,
identical output distribution)
- Markdown original/filtered parsers: hoist constant regexes and cache
the schemes-derived link regexes instead of recompiling per message
- MentionsParser: cache user/channel mention regexes keyed on the
configured pattern; avoid a duplicate channels.find per mention
- AutoTranslate tokenizers: compile constant regexes once at module load
- MentionsServer: skip the empty channel-mention DB query on messages
with no channel mentions; fetch the room member count at most once per
message when handling @all/@here
- API response shaping: replace O(n*m) Array.find/includes scans with
Map/Set lookups (channels/groups/im files, im.members, browseChannels,
Team.findBySubscribedUserIds, LDAP role sync)
- Replace quadratic reduce+spread accumulators with Object.assign,
Object.fromEntries and flatMap (i18n namespace merge, license v2->v3
conversion, settings $unset build, GenericMenu items)
- Avoid repeated settings.get calls in parseUrlsInMessage and
getMarkdownConfig
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ETnjqyMsf3b8LAeQ8fYCbG
Improves performance of several hot code paths without changing behavior: generates random IDs with a single `crypto.randomBytes` call instead of one per character, caches constant regular expressions used by the markdown/mention/autotranslate parsers instead of recompiling them for every message, skips the channel-mention database query for messages without channel mentions, deduplicates the room member count query when a message contains both `@all` and `@here`, and replaces linear array scans and spread-accumulators with Map/Set lookups in API response shaping (files, DM members, directory search and team listing).
0 commit comments