gregsexton / MatchTag

Vim's MatchParen for HTML tags
http://www.vim.org/scripts/script.php?script_id=3818
311 stars 30 forks source link

Why MatchTag is consume resources on filetype=vim (maybe others too)? #25

Closed FelikZ closed 10 years ago

FelikZ commented 10 years ago

I just notices that when Im moving across my custom colorsheme source, there is a huge lags during movements via jk. So I decided to profile what is currently happening and found that MatchTag is trying to match something on current filetype... Checked twice :set ft? so its really equals to vim.

Here is some statistic from profiles:

FUNCTION  <SNR>85_Highlight_Matching_Pair()
Called 85 times
Total time:   0.014041
Self time:   0.014041

389 FUNCTIONS SORTED ON TOTAL TIME
390 count  total (s)   self (s)  function
391    85   0.014041             <SNR>85_Highlight_Matching_Pair()
392    88   0.012402             airline#check_mode()
393    88   0.007818             airline#extensions#whitespace#check()
394   440   0.004540             airline#util#wrap()
395    88   0.004066             airline#statusline()
396   176   0.003881             airline#util#append()
397    88   0.003260             airline#parts#ffenc()
398    85   0.001647             <SNR>97_sync_active_winnr()
399    88   0.000984             airline#parts#iminsert()
400    88   0.000622             airline#parts#paste()
401    88   0.000597             airline#parts#mode()
402    88   0.000511             airline#parts#readonly()
403    88   0.000448             airline#parts#filetype()
404     1   0.000146   0.000129  unite#handlers#_on_cursor_hold()
405     1   0.000051             <SNR>137_garbage_collect()
406     1   0.000017             <SNR>144_restore_statusline()

As you can see, airline in pair with MatchTag crap a little performance. How I can prevent MatchTag to load (e.g. use Highlight_Matching_Pair function)?

gregsexton commented 10 years ago

You want to completely disable MatchTag? Just remove it from your vim directory.

If you want to conditionally disable, you can remove the auto group matchhtmlparen: augroup! matchhtmlparen.

Highlight_Matching_Pair is only called when you move your cursor.

If I'm reading your output correctly, 0.014041 seconds is ~14ms. Divided by 85 is ~0.16 ms per keypress. I doubt that you can notice this lag. I suspect your problem lies elsewhere.