Skip to content

Closes #112 Slow greedy regex#174

Open
harmenwierenga wants to merge 1 commit intofortran-lang:masterfrom
harmenwierenga:fix_slow_floating_point_regex
Open

Closes #112 Slow greedy regex#174
harmenwierenga wants to merge 1 commit intofortran-lang:masterfrom
harmenwierenga:fix_slow_floating_point_regex

Conversation

@harmenwierenga
Copy link
Copy Markdown

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
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