discourse/app/assets/javascripts/pretty-text/engines/discourse-markdown
Régis Hanol 4cb3412a56
PERF: improve `findAllMatches` speed (#22083)
When we introduced unicode support in the regular expressions used in watched words (9a27803) we didn't realize the cost adding the `u` flag would be.

Turns out, it's pretty bad when you have lots of regular expressions to test. A customer had slightly less than 200 watched words, and it would freeze the browser for about 2s on the first check of those regular expressions (roughly 10ms per regular expression).

This commit introduces a new field (`word`) to the serialized watched words which is then converted to a very fast and cheap regular expression on the client-side. We use that regexp to quicly check whether a matcher is even worth trying so that we don't incure the cost of compiling the expensive unicode regexp.

This commit also busts the `WordWatcher` cache since we added a new field to be serialized.

One nice side effect of using `matchAll` instead of a `while / exec` loop is that the likeliness of having a bad regexp matching infinitely is vastly reduced 🙌
2023-06-13 18:34:28 +02:00
..
anchor.js FIX: Generate valid heading ids (#14840) 2021-11-08 20:44:46 +02:00
bbcode-block.js DEV: Update linting setup and fix issues (#17345) 2022-07-06 10:37:54 +02:00
bbcode-inline.js FIX: bbcode URLs not handling paths correctly (#21215) 2023-04-25 11:28:32 +10:00
category-hashtag.js FEATURE: Generic hashtag autocomplete lookup and markdown cooking (#18937) 2022-11-21 08:37:06 +10:00
censored.js FEATURE: Add support for case-sensitive Watched Words (#17445) 2022-08-02 10:06:03 +02:00
code.js DEV: Add support for aliases in HighlightJS languages (#20380) 2023-02-23 15:06:06 -05:00
custom-typographer-replacements.js Double arrow support `↔` (#20288) 2023-02-14 14:24:14 -05:00
d-wrap.js FIX: pretty text allow list (#10977) 2020-10-28 13:22:06 +11:00
emoji.js FEATURE: Add an emoji deny list site setting (#20929) 2023-04-13 15:38:54 +08:00
hashtag-autocomplete.js FIX: Do not cook icon with hashtags (#21676) 2023-05-23 09:33:55 +02:00
helpers.js DEV: Replace deprecated String.prototype.substr() (#16233) 2022-04-01 17:35:17 +02:00
html-img.js DEV: Correct typos and spelling mistakes (#12812) 2021-05-21 11:43:47 +10:00
image-controls.js FEATURE: image grid in posts (experimental) (#21513) 2023-06-07 14:15:57 -04:00
image-grid.js FEATURE: image grid in posts (experimental) (#21513) 2023-06-07 14:15:57 -04:00
mentions.js FEATURE: Enforce mention limits for chat messages (#19034) 2022-12-06 14:54:04 -03:00
newline.js FIX: possible ReDOS in markdown newline rule (#15646) 2022-01-20 22:32:01 +01:00
onebox.js DEV: Correct typos and spelling mistakes (#12812) 2021-05-21 11:43:47 +10:00
paragraph.js DEV: prettier 2.2.1 (#11862) 2021-01-27 12:39:20 +01:00
quotes.js DEV: Extensively use `startsWith()` (#17540) 2022-07-17 20:16:39 +02:00
table.js DEV: Use method definition syntax consistently (#14915) 2021-11-13 14:01:55 +01:00
text-post-process.js DEV: enforces eslint’s curly rule to the codebase (#10720) 2020-09-22 16:28:28 +02:00
upload-protocol.js DEV: Rename secure_media to secure_uploads (#18376) 2022-09-29 09:24:33 +10:00
watched-words.js PERF: improve `findAllMatches` speed (#22083) 2023-06-13 18:34:28 +02:00