optimize newing up the builder
This commit is contained in:
parent
6bda68e35c
commit
3814c21125
@ -48,9 +48,7 @@ function! airline#get_statusline(winnr, active)
|
||||
endif
|
||||
endif
|
||||
|
||||
let info = builder.build()
|
||||
call setwinvar(a:winnr, 'airline_current_info', info)
|
||||
return info.statusline
|
||||
return builder.build()
|
||||
endfunction
|
||||
|
||||
function! airline#update_statusline()
|
||||
|
@ -1,29 +1,25 @@
|
||||
" MIT license. Copyright (c) 2013 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2 fdm=indent
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
function! airline#builder#new(active, highlighter)
|
||||
let builder = {}
|
||||
let builder._sections = []
|
||||
let builder._active = a:active
|
||||
let builder._highlighter = a:highlighter
|
||||
let s:prototype = {}
|
||||
|
||||
function! builder.split(gutter)
|
||||
function! s:prototype.split(gutter)
|
||||
call add(self._sections, ['|', a:gutter])
|
||||
endfunction
|
||||
endfunction
|
||||
|
||||
function! builder.add_section(group, contents)
|
||||
function! s:prototype.add_section(group, contents)
|
||||
call add(self._sections, ['airline_'.a:group, a:contents])
|
||||
endfunction
|
||||
endfunction
|
||||
|
||||
function! builder.add_raw(text)
|
||||
function! s:prototype.add_raw(text)
|
||||
call add(self._sections, ['_', a:text])
|
||||
endfunction
|
||||
endfunction
|
||||
|
||||
function! builder._group(group)
|
||||
function! s:prototype._group(group)
|
||||
return self._active ? a:group : a:group.'_inactive'
|
||||
endfunction
|
||||
endfunction
|
||||
|
||||
function! builder.build()
|
||||
function! s:prototype.build()
|
||||
let line = '%{airline#check_mode()}'
|
||||
let side = 0
|
||||
let prev_group = ''
|
||||
@ -53,10 +49,14 @@ function! airline#builder#new(active, highlighter)
|
||||
let prev_group = section[0]
|
||||
endfor
|
||||
|
||||
return {
|
||||
\ 'statusline': line,
|
||||
\ }
|
||||
endfunction
|
||||
return line
|
||||
endfunction
|
||||
|
||||
function! airline#builder#new(active, highlighter)
|
||||
let builder = copy(s:prototype)
|
||||
let builder._sections = []
|
||||
let builder._active = a:active
|
||||
let builder._highlighter = a:highlighter
|
||||
return builder
|
||||
endfunction
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user