Skip to content

Suggestion: cache compiled regular expressions #184

Description

@evilsocket

Hi, I love your project, thanks for creating it and making it free!

I've noticed that the regex builtin functions always create a new instance of the regular expression when executed, I think this could be optimized by creating a global HashMap (or better, a DashMap to make it super fast in a concurrent context) cache where the key would be re_str and the value the compiled object itself, and then using this cache from within the builtin functions body. This would avoid parsing the regex and allocating a new object for each invocation ... what do you think? If you like this optimization and don't mind adding the DashMap dependency, I'll gladly work on it myself and send a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions