Skip to content

Improve regex performance (keep parsed result for later) #4432

@jasonwilliams

Description

@jasonwilliams

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:

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 problembugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions