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

Closes #112 Slow greedy regex #174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

harmenwierenga
Copy link

When applying fprettify using the --case 1 1 1 1 option, the following code takes a long time to format because of the matching of floating point constants:

program main
   implicit none
   real, dimension(2) :: array
   array = [9.23529879234512349823d-02, 3.34099894387578238101e-01]
   print *, sum(array)
end program main

On my computer, it takes 6.5 seconds to format. With my simplification of F90_NUMBER_ALL_RE, it still takes 3.2 seconds to format. Finally applying the fix from #112, it only takes 0.13 seconds to format.

A part of this PR is already adressed in #99, but it appears to be stalled, and I hope that this small fix is easier to review. I noticed the issue because formatting some files at work took > 5 minutes, and a profiler showed that 99% of the time was spent matching these regexes. Apparently this was also noticed by @Jellby and @zaikunzhang in the past, see issue.

… Also remove superfluous matching greedy regex from typed constant regex, dramatically improving speed
@harmenwierenga harmenwierenga changed the title Closes #112 Improve speed of number literal matching Closes #112 Jul 6, 2024
@harmenwierenga harmenwierenga changed the title Closes #112 Closes #112 Slow greedy regex Jul 6, 2024
GhostOps77 added a commit to GhostOps77/fprettify that referenced this pull request Aug 10, 2024
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.

1 participant