joypixels / emojione

[Archived] The world's largest independent emoji font. Maintained at https://github.com/joypixels/emoji-toolkit.
https://www.joypixels.com
Other
4.46k stars 536 forks source link

Fix Performance on multiple invocation of toImage #627

Closed Wattos closed 1 year ago

Wattos commented 5 years ago

We currently VueJs and apply the toImage function on a lot of components independently.

The toImage function builds the regex for the emojis every single time. After doing a detailed performance analysis, the toImage function spend most of its time to build the regex. Caching the result of these two functions immediately improved performance.

sherlock1982 commented 5 years ago

Even more: function replaceAll is actually called with the same find parameter all the time. Therefore search variable is also const. No need to compile regex every time.