Fortran-FOSS-Programmers / ford

Automatically generates FORtran Documentation from comments within the code.
https://forddocs.readthedocs.io
GNU General Public License v3.0
410 stars 134 forks source link

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

Closed d7919 closed 1 day ago

d7919 commented 1 week ago

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.

d7919 commented 1 week ago

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 commented 1 week ago

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