Christian Brabandt <[email protected]> wrote:

> Hi,
> here is another slight improvement to syntax/vim.vim
>
> When analyzing vim/vim#2712 I found that the syntax definition
> vimNotation is notorious bad. I think this is, because it uses many OR
> branches, which the new engine is known not to handle good. Therefore,
> enable explicitly the old engine for parsing that kind of items.
>
> That made an improvement from
>
> TOTAL      COUNT  MATCH   SLOWEST     AVERAGE   NAME               PATTERN
> 0.160759   4571   2149    0.001149    0.000035  vimNotation        
> \(\\\|<lt>\)\=<\([scamd]-\)\{0,4}x\=\(f\d\{1,2}\|[^ 
> \t:]\|cr\|lf\|linefeed\|return\|k\=del\%[ete]\|bs\|backspace\|tab\|esc\|right\|left\|help\|undo\|insert\|ins\|k\=home\|k\=end\|kplus\|kminus\|kdivide\|
>
> TOTAL      COUNT  MATCH   SLOWEST     AVERAGE   NAME               PATTERN
> 0.001967   3087   0       0.000092    0.000001  vimNotation        
> \%#=1\(\\\|<lt>\)\=<\([scamd]-\)\{0,4}x\=\(f\d\{1,2}\|[^ 
> \t:]\|cr\|lf\|linefeed\|return\|k\=del\%[ete]\|bs\|backspace\|tab\|esc\|right\|left\|help\|undo\|insert\|ins\|k\=home\|k\=end\|kplus\|kminus\|kdiv
>
>
> diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim
> index 48b02970e..cbc0662ce 100644
> --- a/runtime/syntax/vim.vim
> +++ b/runtime/syntax/vim.vim
> @@ -416,7 +416,7 @@ syn match   vimMenuBang     "!"     contained skipwhite 
> nextgroup=@vimMenuList
>  " Angle-Bracket Notation (tnx to Michael Geddes) {{{2
>  " ======================
>  syn case ignore
> -syn match      vimNotation     
> "\(\\\|<lt>\)\=<\([scamd]-\)\{0,4}x\=\(f\d\{1,2}\|[^ 
> \t:]\|cr\|lf\|linefeed\|return\|k\=del\%[ete]\|bs\|backspace\|tab\|esc\|right\|left\|help\|undo\|insert\|ins\|k\=home\|k\=end\|kplus\|kminus\|kdivide\|kmultiply\|kenter\|kpoint\|space\|k\=\(page\)\=\(\|down\|up\|k\d\>\)\)>"
>  contains=vimBracket
> +syn match      vimNotation     
> "\%#=1\(\\\|<lt>\)\=<\([scamd]-\)\{0,4}x\=\(f\d\{1,2}\|[^ 
> \t:]\|cr\|lf\|linefeed\|return\|k\=del\%[ete]\|bs\|backspace\|tab\|esc\|right\|left\|help\|undo\|insert\|ins\|k\=home\|k\=end\|kplus\|kminus\|kdivide\|kmultiply\|kenter\|kpoint\|space\|k\=\(page\)\=\(\|down\|up\|k\d\>\)\)>\%#=0"
>  contains=vimBracket
>  syn match      vimNotation     
> "\(\\\|<lt>\)\=<\([scam2-4]-\)\{0,4}\(right\|left\|middle\)\(mouse\)\=\(drag\|release\)\=>"
>      contains=vimBracket
>  syn match      vimNotation     
> "\(\\\|<lt>\)\=<\(bslash\|plug\|sid\|space\|bar\|nop\|nul\|lt\)>"             
>   contains=vimBracket
>  syn match      vimNotation     '\(\\\|<lt>\)\=<C-R>[0-9a-z"%#:.\-=]'he=e-1   
>                   contains=vimBracket


Hi Christian

I see that your patch adds \%#=1 at the beginning of
vimNotation's regexp and adds \%#=0 at the end of it,

According to  :help NFA  the \%#=0  should be prepended
to the pattern.  So why add \%#=0 at the end?

In fact adding \%#=0 at the end seems to break the regexp.
I see things like <F2> which should match vimNotation no
longer match it.

But at least I confirm that adding \%#=1 at the beginning
of vimNotation  (without \%#=0 at the end) does indeed
help to make the regexp faster.

Regards
Dominique

-- 
-- 
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