Skip to content
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: cache repeat regexp processing for toShort #57

Merged
merged 1 commit into from
Aug 18, 2023

Conversation

JoshuaKGoldberg
Copy link
Contributor

@JoshuaKGoldberg JoshuaKGoldberg commented Apr 7, 2023

Caches the escaped search regex used in ns.toShort, under unicodeCharRegexEscapedSearch(). This way each call to toShort doesn't need to call ns.escapeRegExp on ns.unicodeCharRegex().

Additionally extracts the replacer function used in str.replace to a shared one - that way it can be used in both ns.toShort and ns.replaceAll.

@marvinhagemeister is the one who first prototyped these changes; we'd paired looking at https://github.com/JoshuaKGoldberg/repros/tree/draft-js-emoji-plugin-emoji-toolkit-performance. See #58 for more context.

Fixes #58

Co-authored-by: Marvin Hagemeister hello@marvinh.dev

@JoshuaKGoldberg
Copy link
Contributor Author

Ping ... @caseyahenson as last repository commiter? Any chance this PR can be reviewed?

@caseyahenson caseyahenson merged commit 6337202 into joypixels:master Aug 18, 2023
@JoshuaKGoldberg JoshuaKGoldberg deleted the to-short-cached branch August 18, 2023 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Poor performance when calling toShort repeatedly (uncached repeated regexp processing)
2 participants