Alexey-T / CudaText

Cross-platform text editor, written in Free Pascal
Mozilla Public License 2.0
2.39k stars 166 forks source link

Mass regex replace in file with lexer is very slow #5487

Closed pintassilgo closed 2 months ago

pintassilgo commented 2 months ago

The same demo file from the other issue: bug5473.txt (extract from zip).

Copy the entire content of the file to a new tab (Ctrl+A to select all, Ctrl+C to copy, Ctrl+N to new tab and Ctrl+V to paste).

Try to replace, with regex enabled, \w by r. On my machine, it's done in like 15 seconds if this new tab has no lexer (none), that's good. But if I repeat the test after set this new tab to use Markdown lexer (or any other, probably), replace would take like 10 minutes (I couldn't wait to time it).

There's no reason for that, because when I set the lexer as Markdown it took like 5s to parse the file and color it. So it should take 15 seconds to replace + 5 seconds to parse the new content, not many minutes.

Maybe the fix is similar to what you've done in #5353, I don't know.

Tested with clean Cuda.

pintassilgo commented 2 months ago

Bonus: even when using a tab without lexer, mass regex replace is slow if you use big value for find_hi_max_lines like 100000, when both Hi and Im are enabled. It's expected that Cuda hangs a little when you type \w in find input, because it will find and highlight thousands of matches. But this highlighting is finished in a couple of seconds for me, it's not a reason for replacing time to jump from seconds to minutes.

Alexey-T commented 2 months ago

1st issue: fixed! 2nd one: confirmed. working on it.

Alexey-T commented 2 months ago

fixed 2nd too. beta for qt5 - updated.

pintassilgo commented 2 months ago

Thanks, confirmed fixed, way faster now.

Please keep it open for a while because later I'll test more if there is any other option I use causing slowdown to regex replace, because despite the big improvement from your fix my Cuda is still slower than clean Cuda so I need to check. Clean Cuda takes ~15s, my Cuda takes ~95s.

Edit: nevermind, I guess it was because the regex substitution button $0 was enabled and it makes things slower.