From a104e40b10d01f7ae6db6c010e59904daf61ce6b Mon Sep 17 00:00:00 2001 From: Cimbali Date: Tue, 9 Jan 2018 20:07:54 +0100 Subject: [PATCH] Cache only git calls, not bufname and fnamemodify --- autoload/airline/extensions/fugitiveline.vim | 27 ++++++++++---------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/autoload/airline/extensions/fugitiveline.vim b/autoload/airline/extensions/fugitiveline.vim index 831f9310..255e09d9 100644 --- a/autoload/airline/extensions/fugitiveline.vim +++ b/autoload/airline/extensions/fugitiveline.vim @@ -15,21 +15,22 @@ else endif function! airline#extensions#fugitiveline#bufname() - if exists('b:fugitive_name') - return b:fugitive_name + if !exists('b:fugitive_name') + let b:fugitive_name = '' + try + let buffer = fugitive#buffer() + if buffer.type('blob') + let b:fugitive_name = buffer.repo().translate(buffer.path()) + endif + catch + endtry endif - let b:fugitive_name = fnamemodify(bufname('%'), s:fmod) - - try - let buffer = fugitive#buffer() - if buffer.type('blob') - let b:fugitive_name = fnamemodify(buffer.repo().translate(buffer.path()), s:fmod) - endif - catch - endtry - - return b:fugitive_name + if empty(b:fugitive_name) + return fnamemodify(bufname('%'), s:fmod) + else + return fnamemodify(b:fugitive_name, s:fmod) + endif endfunction function! airline#extensions#fugitiveline#init(ext)