fprettify icon indicating copy to clipboard operation
fprettify copied to clipboard

Slow greedy regex

Open danielhollas opened this issue 4 years ago • 0 comments
trafficstars

Greedily matching numbers in F90_CONSTANTS_TYPES_RE is super slow for numbers with many digits.

https://github.com/pseewald/fprettify/blob/cb254022c2034ad3b8f744f4dad1bf5b7438815d/fprettify/init.py#L475

Kudos to @Jellby and @zaikunzhang for independently discovering this and fixing it as part of their PRs in https://github.com/pseewald/fprettify/pull/99/commits/2f766f33ed795ee69d0ac404e699e5475ff52f3f and https://github.com/pseewald/fprettify/pull/106/commits/bf41457c782997e378144297e764092d09a3fa5f, respectively.

Since those PRs are not yet merged, I am documenting the issue here for clarity. As one data point, parsing one file with 600 lines containing a lot of numbers went from 12s to 1s after the fix!

danielhollas avatar May 31 '21 12:05 danielhollas