Dominique wrote:

> Consider those 3 commands using the new regexp engine
> which only differ by the length of the line being
> matched:
> 
> $ vim -u NONE -c'set re=0 hls' -c'norm aaaa'   -c'/\(\)\(a*\1*\1*\1*\)*$' 
> -c'q!'
> $ vim -u NONE -c'set re=0 hls' -c'norm aaaaa'  -c'/\(\)\(a*\1*\1*\1*\)*$' 
> -c'q!'
> $ vim -u NONE -c'set re=0 hls' -c'norm aaaaaa' -c'/\(\)\(a*\1*\1*\1*\)*$' 
> -c'q!'

These are not realistic patterns, I don't see why someone would want to
use this.

> Matching becomes very slow as the line length increases.
> Above 3 commands with vim-8.0.134 take respectively:
> 
>    0.8sec
>    3.9sec
>  356.4sec (at half time, it shows "search hit BOTTOM, continuing at TOP")
> 
> The same commands with 'set re=1' instead of 'set re=0' are almost
> instantaneous (0.017 sec).
> 
> Timing with the new regexp engine grows significantly as we add only
> 1 char to the line being matched. I thought that the complexity of new
> regexp engine was linear with the length of the line being matched,
> but that's clearly not the case here.

An NFA does not support back references.  This is implemented in a crude
way, which indeed can't possibly be linear.

> Not only it's slow, but:
> - CTRL-C does not interrupt the search

Should be possible to fix that.

> - and the amount of memory that Vim uses keeps increasing during the
>   first half of the time i.e. until it shows
>   "search hit BOTTOM, continuing at TOP".
> 
> Can't vim simplify the regexp here? i.e. when something like x*x*x*
> should be equivalent to x* if x is an atom.  So the part  \1*\1\*\1*
> should be equivalent to  \1*  and in that case, the following
> line is much quicker (0.21 sec):
> 
> $ vim -u NONE -c'set re=0 hls' -c'norm aaaaaa' -c'/\(\)\(a*\1*\)*$' -c'q!'

Yeah, but why optimize for this, since it's very unlikely someone would
try to use this pattern.

-- 
hundred-and-one symptoms of being an internet addict:
156. You forget your friend's name but not her e-mail address.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui