discourse/app/assets/javascripts/pretty-text
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
..
addon FIX: skip iframe URLs with relative paths in pretty text sanitizer. (#21714) 2023-05-24 16:14:18 +05:30
app DEV: Move pretty-text into an ember-addon format (#9689) 2020-05-07 12:37:47 -04:00
config DEV: Update ember-cli to 4.12.0 (#21074) 2023-04-19 12:58:29 +02:00
engines/discourse-markdown PERF: improve `findAllMatches` speed (#22083) 2023-06-13 18:34:28 +02:00
.npmrc DEV: Prevent npm usage (#13945) 2021-08-04 22:04:58 +02:00
ember-cli-build.js DEV: Update ember-cli to 4.12.0 (#21074) 2023-04-19 12:58:29 +02:00
index.js REFACTOR: Support bundling our `admin` section as an ember addon 2020-09-22 15:14:29 -04:00
jsconfig.json DEV: Add `discourse/tests` to jsconfig (#19031) 2022-11-15 11:33:56 +00:00
package.json Build(deps-dev): Bump @babel/core in /app/assets/javascripts (#22026) 2023-06-12 16:50:43 +02:00