-
-
Notifications
You must be signed in to change notification settings - Fork 460
Open
Labels
E-MediumMedium difficulty problemMedium difficulty problembugSomething isn't workingSomething isn't working
Description
Describe the bug
Right now we parse and evaluate every regex twice. Once to check that its valid then again when we actually need to compile it.
This is not efficient as we're throwing away a compiled regex, only to rebuild the same thing again during runtime.
We can't afford to skip the first check, as the specification says they need to be checked during parsing, so the best solution is to keep the compiled regex object we created and pass it through to the AST, then in builtins we can reuse that object instead of creating a new one.
So:
- Pass the compiled regex into the RegularExpressionLiteral
- https://github.com/boa-dev/boa/blob/main/core/parser/src/lexer/token.rs#L173 would need to support holding a compiled regex
- The compiled regex comes out here and is passed into AstRegex
- This is then held here
- and so on
The other option is to find out if regress have a cheap way of checking if a regex string is valid without doing a full compile
Metadata
Metadata
Assignees
Labels
E-MediumMedium difficulty problemMedium difficulty problembugSomething isn't workingSomething isn't working