From 152c9195aecea8b4549205bc810081ee26c14d9a Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 3 Feb 2014 19:58:24 +0100 Subject: [PATCH] Check `&diff` first in fugitive_diff autocmds This avoids calling `s:diff_window_count` in the common (non-diff) case. --- plugin/fugitive.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 2803925..6f09f09 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -1389,8 +1389,8 @@ call s:command("-bar -nargs=* -complete=customlist,s:EditComplete Gsdiff :execut augroup fugitive_diff autocmd! - autocmd BufWinLeave * if s:diff_window_count() == 2 && &diff && getbufvar(+expand(''), 'git_dir') !=# '' | call s:diffoff_all(getbufvar(+expand(''), 'git_dir')) | endif - autocmd BufWinEnter * if s:diff_window_count() == 1 && &diff && getbufvar(+expand(''), 'git_dir') !=# '' | call s:diffoff() | endif + autocmd BufWinLeave * if &diff && s:diff_window_count() == 2 && getbufvar(+expand(''), 'git_dir') !=# '' | call s:diffoff_all(getbufvar(+expand(''), 'git_dir')) | endif + autocmd BufWinEnter * if &diff && s:diff_window_count() == 1 && getbufvar(+expand(''), 'git_dir') !=# '' | call s:diffoff() | endif augroup END function! s:diff_window_count()