Skip to content

Files/Generated: Use SlidingWindow instead of getline

Going over the file with a smaller regex first and skipping the relatively slower getline loop if there's no matches at all in the file.

before: Check files/generated for source:rakudo_2024.09-1 done (0.263s)
after:  Check files/generated for source:rakudo_2024.09-1 done (0.108s)

See if you find this improvement worthwhile. This is for a package where:

  • 2933 files are being visited by the visit_patched_files method of this check
  • 2611 files survive the is_open_ok check
  • 6669 calls to $sfd->readwindow happen
  • 2603 files get an early return from the method after the "quick" check
  • 1971 lines are matched against the regexes inside

There's probably some tuning still possible here, like making the blocksize smaller could be better?

Merge request reports

Loading