Skip to content

Regex memoization #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 8, 2024
Merged

Regex memoization #31

merged 3 commits into from
Sep 8, 2024

Conversation

StavromulaBeta
Copy link
Collaborator

Regex and Regex-match now take two string parameters, performing the match immediately. Under the hood this uses memoization (using tables) to prevent the regex being recompiled.

else
{
reg = gc_flatmalloc(sizeof *reg);
const int status = regcomp(reg, reg_str, REG_EXTENDED | REG_NEWLINE);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that previously Regex also used the REG_NOSUB flag when compiling (Regex-match does not since it needs those subexpressions). I have no idea if it could affect the performance for Regex, though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I considered having different memoization buffers for the two functions but this felt easier - if the performance becomes concern I'll do that.

@StavromulaBeta StavromulaBeta merged commit 8c07484 into master Sep 8, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants