break early implicit if return code is not 0.

This commit is contained in:
Bailey Ling
2013-08-22 03:12:07 +00:00
parent db3a4b1df6
commit e83e12447e
3 changed files with 13 additions and 18 deletions

View File

@@ -13,29 +13,24 @@ else
endif
if v:version >= 704
function! airline#util#exec_funcrefs(list, break_early, ...)
function! airline#util#exec_funcrefs(list, ...)
for Fn in a:list
if a:break_early
if Fn()
return 1
endif
else
call Fn()
let code = Fn(a:000)
if code != 0
return code
endif
endfor
return 0
endfunction
else
function! airline#util#exec_funcrefs(list, break_early, ...)
function! airline#util#exec_funcrefs(list, ...)
" for 7.2; we cannot iterate the list, hence why we use range()
" for 7.3-[97, 328]; we cannot reuse the variable, hence the {}
for i in range(0, len(a:list) - 1)
let Fn{i} = a:list[i]
if a:break_early
if Fn{i}()
return 1
endif
else
call Fn{i}()
let code = Fn{i}(a:000)
if code != 0
return code
endif
endfor
return 0