It's also slow with at least:
re=1 re=2
----------------------------------
[a-z]\{1,8000} 0.004s 5.890s
\h\{1,8000} 0.004s 5.824s
I see that not only the complexity to match is O(n^2)
with the new regexp engine for the regexp .\{1,n},
but the complexity is also linear with the length N
of the line being matched. So the complexity seems
to be: O(N*n^2).
Time to match .\{1,8000} with line length of 1, 2, 4, 8, 16, 32:
line to match re=1 re=2
----------------------------------------------------
1 0.004s 0.016s
12 0.004s 1.527s
1234 0.004s 4.391s
12345678 0.004s 10.167s
1234567890123456 0.004s 21.466s
12345678901234567890123456789012 0.004s 44.849s
This was measured using for example:
$ time vim -X -u NONE -c 'set re=2' \
-c 'call feedkeys("i12345678\<esc>/.\\{1,8000}\<cr>:q!\<cr>")'
real 0m10.167s
user 0m10.085s
sys 0m0.024s
The non-greedy version is fast:
$ time vim -X -u NONE -c 'set re=2' \
-c 'call feedkeys("i12345678\<esc>/.\\{-1,8000}\<cr>:q!\<cr>")'
real 0m0.056s
ser 0m0.020s
sys 0m0.028s
> I would expect the old engine to be slower when what's being matched may
> fail.
I cannot find such an example. The old regexp engine
seems always much faster with things like \{1,8000}
Dominique