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

Don't store sub-groups where not needed in regex and other processing optimisations #669

Merged
merged 6 commits into from
Nov 20, 2024

Conversation

d7919
Copy link
Contributor

@d7919 d7919 commented Nov 12, 2024

Tweaks SRC_CAPTURE_STR to avoid capturing the logical groups in this regex as we don't use them. This gives a slight optimisation to the "Processing comments" stage.

There are likely a few other places in sourceform that similar adjustments could be made, but they are less likely to give a noticeable speed up as, at least for the project I'm testing with, the SRC_CAPTURE_STR regex search dominates the processing comments stage.

Gives a slight optimisation to the "Processing comments" stage.
Tries to avoid potential backtracking from the first group and the
possible leading whitespace given that the first group can also match
leading whitespace.
@d7919
Copy link
Contributor Author

d7919 commented Nov 12, 2024

Have now included another tweak which for the project I'm testing with has led to a reduction in the time spent processing comments by a factor of four, without missing any matches or hitting new matches (i.e. it gives the same results).

I think the regex as is (and before any of the changes in this PR) might have some false positives, e.g. matching ! end subroutine name as a valid end.

@d7919
Copy link
Contributor Author

d7919 commented Nov 12, 2024

OK, now also fixed the potential match of a commented out line when searching for the end of a block.

@d7919 d7919 changed the title Draft: Don't store sub-groups where not needed in regex Don't store sub-groups where not needed in regex and other processing optimisations Nov 12, 2024
@ZedThree ZedThree merged commit 8b9fbb6 into Fortran-FOSS-Programmers:master Nov 20, 2024
6 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.

3 participants