Skip to content
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

Stop constantly recompiling regex in extract_multiple #5

Merged
merged 2 commits into from Mar 2, 2022
Merged

Stop constantly recompiling regex in extract_multiple #5

merged 2 commits into from Mar 2, 2022

Conversation

mohawk2
Copy link
Collaborator

@mohawk2 mohawk2 commented Jan 28, 2022

With this change, PDL::NiceSlice when used with PDL::LinearAlgebra (a 6700-line file) goes from taking about 10 seconds to be processed using Filter::Simple, to about 0.6s.

The reason is that the regex in m/\G$func/gc was constantly being recompiled (in the above case, NYTProf reported it was about 250k times) since $func kept being assigned from $func[$i], i.e. changed. By updating it to be recompiled at the start of the function with the \G prefixed, then just using the stored version $func[$i], this recompilation is avoided.

@mohawk2 mohawk2 merged commit 747e118 into steve-m-hay:master Mar 2, 2022
@mohawk2 mohawk2 deleted the faster-extract_multiple branch March 2, 2022 15:58
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.

None yet

1 participant