inccommand: improve performance #6949

During a preview, we can stop looking for matches after we got enough
lines for the preview buffer.

Because of this perf improvement, the 'redrawtime' test needs to be
slowed down in a different way: _long_ lines instead of just many lines.
This commit is contained in:
KillTheMule
2017-07-03 09:36:43 +02:00
committed by Justin M. Keyes
parent 0fb4d173f8
commit 619838f85d
3 changed files with 609 additions and 15 deletions

View File

@@ -3332,7 +3332,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout)
// Check for a match on each line. // Check for a match on each line.
linenr_T line2 = eap->line2; linenr_T line2 = eap->line2;
for (linenr_T lnum = eap->line1; for (linenr_T lnum = eap->line1;
lnum <= line2 && !(got_quit || aborting()); lnum <= line2 && !(got_quit || aborting())
&& (!preview || matched_lines.size <= (size_t)p_cwh);
lnum++) { lnum++) {
long nmatch = vim_regexec_multi(&regmatch, curwin, curbuf, lnum, long nmatch = vim_regexec_multi(&regmatch, curwin, curbuf, lnum,
(colnr_T)0, NULL); (colnr_T)0, NULL);

File diff suppressed because one or more lines are too long

View File

@@ -986,7 +986,7 @@ describe(":substitute, inccommand=split", function()
-- Set 'redrawtime' to minimal value, to ensure timeout is triggered. -- Set 'redrawtime' to minimal value, to ensure timeout is triggered.
feed_command("set redrawtime=1 nowrap") feed_command("set redrawtime=1 nowrap")
-- Load a big file. -- Load a big file.
feed_command("silent edit! test/functional/fixtures/bigfile.txt") feed_command("silent edit! test/functional/fixtures/bigfile_oneline.txt")
-- Start :substitute with a slow pattern. -- Start :substitute with a slow pattern.
feed([[:%s/B.*N/x]]) feed([[:%s/B.*N/x]])
wait() wait()
@@ -996,19 +996,19 @@ describe(":substitute, inccommand=split", function()
-- Assert that preview cleared (or never manifested). -- Assert that preview cleared (or never manifested).
screen:expect([[ screen:expect([[
0000;<control>;Cc;0;BN;;;;;N;N| 0000;<control>;Cc;0;BN;;;;;N;N|
0001;<control>;Cc;0;BN;;;;;N;S| 2F923;CJK COMPATIBILITY IDEOGR|
0002;<control>;Cc;0;BN;;;;;N;S| 2F924;CJK COMPATIBILITY IDEOGR|
0003;<control>;Cc;0;BN;;;;;N;E| 2F925;CJK COMPATIBILITY IDEOGR|
0004;<control>;Cc;0;BN;;;;;N;E| 2F926;CJK COMPATIBILITY IDEOGR|
0005;<control>;Cc;0;BN;;;;;N;E| 2F927;CJK COMPATIBILITY IDEOGR|
0006;<control>;Cc;0;BN;;;;;N;A| 2F928;CJK COMPATIBILITY IDEOGR|
0007;<control>;Cc;0;BN;;;;;N;B| 2F929;CJK COMPATIBILITY IDEOGR|
0008;<control>;Cc;0;BN;;;;;N;B| 2F92A;CJK COMPATIBILITY IDEOGR|
0009;<control>;Cc;0;S;;;;;N;CH| 2F92B;CJK COMPATIBILITY IDEOGR|
000A;<control>;Cc;0;B;;;;;N;LI| 2F92C;CJK COMPATIBILITY IDEOGR|
000B;<control>;Cc;0;S;;;;;N;LI| 2F92D;CJK COMPATIBILITY IDEOGR|
000C;<control>;Cc;0;WS;;;;;N;F| 2F92E;CJK COMPATIBILITY IDEOGR|
000D;<control>;Cc;0;B;;;;;N;CA| 2F92F;CJK COMPATIBILITY IDEOGR|
:%s/B.*N/x^ | :%s/B.*N/x^ |
]]) ]])