Merge pull request #1012 from chrisbra/performance

Some improvements for the buflist implementation
This commit is contained in:
Christian Brabandt 2016-02-09 19:43:46 +01:00
commit cc219dbc10
1 changed files with 15 additions and 17 deletions

View File

@ -14,25 +14,23 @@ function! airline#extensions#tabline#buflist#list()
endif
let buffers = []
let cur = bufnr('%')
" If this is too slow, we can switch to a different algorithm.
" Basically branch 535 already does it, but since it relies on
" BufAdd autocommand, I'd like to avoid this if possible.
for nr in range(1, bufnr('$'))
if buflisted(nr) && bufexists(nr)
let toadd = 1
for ex in s:excludes
if match(bufname(nr), ex) >= 0
let toadd = 0
break
endif
endfor
if getbufvar(nr, 'current_syntax') == 'qf'
let toadd = 0
endif
if s:exclude_preview && getbufvar(nr, '&bufhidden') == 'wipe' && getbufvar(nr, '&buftype') == 'nofile'
let toadd = 0
endif
if toadd
call add(buffers, nr)
if buflisted(nr)
" Do not add to the bufferlist, if either
" 1) buffername matches exclude pattern
" 2) buffer is a quickfix buffer
" 3) exclude preview windows (if 'bufhidden' == wipe
" and 'buftype' == nofile
if (!empty(s:excludes) && match(bufname(nr), join(s:excludes, '\|')) > -1) ||
\ (getbufvar(nr, 'current_syntax') == 'qf') ||
\ (s:exclude_preview && getbufvar(nr, '&bufhidden') == 'wipe'
\ && getbufvar(nr, '&buftype') == 'nofile')
continue
endif
call add(buffers, nr)
endif
endfor