2015-05-22 11:45 GMT+03:00 Dominique Pellé <dominique.pe...@gmail.com>: > Christian Wellenbrock <christian.wellenbr...@gmail.com> wrote: > >> I attached a yaml file as example. Please open it with vim to test >> the highlighting speed. Scolling and searching is very slow. >> Tested on vim 7.3.1106 > > Viewing your attached yaml file seems fast for me with vim-7.4.729, > both with 'set re=0' or 'set re=1'.
I have relatively recently send an update. If you see help for :h b:yaml_schema then you have this update because I also added support for different schemas then. It also contained a number of fixes to the regexes: most notable is that some regexes no longer care about non-printable characters (YAML definition explicitly disallows them in a number of places and my highlighting was as close to YAML definition as possible, so you got a regex `\%([\n\r\uFEFF \t]\@!\p\)` used in *loads* of places and that was very slow). > > Anyway, looking at vim/runtime/syntax/yaml.vim, I see > several [0-9] in regexp which could be replaced by \d > > This is what :help regexp says: > > === BEGIN QUOTE === > - Matching with a collection can be slow, because each character in > the text has to be compared with each character in the collection. > Use one of the other atoms above when possible. Example: "\d" is > much faster than "[0-9]" and matches the same characters. > === END QUOTE === > > But I wonder whether this piece of advice is still true. > In regexp_nfa.c, I see this comment: > > 1525 /* > 1526 * Try to reverse engineer character classes. For > example, > 1527 * recognize that [0-9] stands for \d and [A-Za-z_] for > \h, > 1528 * and perform the necessary substitutions in the NFA. > 1529 */ > > So probably [0-9] is as efficient now than \d at least with the new > NFA regexp engine. > > With 'set re=0', syntime report says: > > TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN > 0.173880 349 0 0.001465 0.000498 yamlFloat > [^[\]{}, \t]\@1<!\%([+-]\=\%(\%(\d[0- > 0.043657 349 0 0.000798 0.000125 yamlInteger > [^[\]{}, \t]\@1<!\%([+-]\=\%(0\%(b[0- > 0.007699 621 602 0.000065 0.000012 yamlPlainScalar > \%([^\-?:,[\]{}#&*!|>'"%@`\n\r\uFEFF > 0.004388 621 367 0.000073 0.000007 yamlBlockMappingKey > \%#=1^\s*\zs\%([^\-?:,[\]{}#&*!|>'"%@ > > 0.004233 386 0 0.000078 0.000011 > yamlBlockCollectionItemStart ^\s*\zs-\%(\s\+-\)*\s > 0.003241 386 0 0.000043 0.000008 yamlComment > \%\(^\|\s\)# > 0.003233 349 0 0.000045 0.000009 yamlNull > [^[\]{}, \t]\@1<!\~[^[\]{}, \t]\@! > 0.002419 386 0 0.000080 0.000006 > yamlBlockMappingMerge ^\s*\zs<<\ze:\%(\s\|$\) > 0.000917 347 347 0.000013 0.000003 yamlKeyValueDelimiter \s*: > 0.000465 347 347 0.000005 0.000001 yamlKeyValueDelimiter \s*: > 0.000312 386 0 0.000007 0.000001 yamlDocumentEnd > ^\.\.\.\ze\%(\s\|$\) > 0.000193 386 0 0.000002 0.000001 yamlMappingKeyStart ?\ze\s > 0.000166 386 0 0.000002 0.000000 yamlFlowCollection \[ > 0.000145 386 0 0.000003 0.000000 yamlDocumentStart > ^---\ze\%(\s\|$\) > 0.000138 386 0 0.000001 0.000000 yamlDirective > ^\ze%[^\n\r\uFEFF \t]\+\s\+ > 0.000138 386 0 0.000001 0.000000 yamlAnchor > &[^\n\r\uFEFF \t,[\]{}]\+ > 0.000135 386 0 0.000001 0.000000 yamlFlowMapping { > 0.000135 386 0 0.000001 0.000000 yamlAlias > \*[^\n\r\uFEFF \t,[\]{}]\+ > 0.000129 386 0 0.000002 0.000000 yamlFlowString ' > 0.000123 386 0 0.000002 0.000000 yamlFlowString " > 0.000115 386 0 0.000003 0.000000 yamlNodeTag > !<\%(%\x\x\|[[:alnum:]_\-]\|[#/;?:@&= > > 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 vim_dev+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- -- 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.