2072 / PHP-Indenting-for-VIm

The official VIm indent script for PHP
http://www.2072productions.com/to/phpindent.txt
128 stars 29 forks source link

indent/php.vim contributing to slow start-up time #15

Closed mmikitka closed 11 years ago

mmikitka commented 11 years ago

I have been profiling the Vim start-up time of PHP files on my computer, and observed indent/php.vim to be a significant contributor.

I am loading a 4600-line file, and it takes about 2 seconds to execute the routines. The loaded file is from the Drupal 7.22 release: drupal/includes/form.inc.

To access the file:

  1. Download at https://drupal.org/download
  2. Unpack tgz
  3. Access drupal/includes/form.inc

Here are the relevant computer specs:

OS: Ubuntu 12.04 Hardware: Core i7, 8GB RAM PHP indent: /usr/share/vim/vim73/indent/php.vim Loaded file:

I ran the following command to generate the profile:

vim --startuptime vim_startup.log form.inc

Here is the profile output:

times in msec clock self+sourced self: sourced script clock elapsed: other lines

000.004 000.004: --- VIM STARTING ---

...

1198.451 933.461 933.461: sourcing /usr/share/vim/vim73/indent/php.vim

...

2163.653 932.103 932.103: sourcing /usr/share/vim/vim73/indent/php.vim

Thanks

2072 commented 11 years ago

This is probably caused by the syntax analysis, The PHP indent script sets the option php_sync_method of PHP syntax script to 0 which causes the whole file to be analysed for syntax colouring.

Look for the line "let php_sync_method = 0" (line 308) and comment it and see if it makes a difference.