highlighter: slight performance increase
do not access get() function twice. We can assign the result to a variable and use it a second time. Should speed up the highligther part of the code by a bit. Since I was already touching s:Get(), also get rid of the default parameter, as it always has been the empty string.
This commit is contained in:
parent
96352f9b53
commit
c65d7fe36b
|
@ -92,10 +92,10 @@ function! airline#highlighter#exec(group, colors)
|
|||
let colors = s:CheckDefined(colors)
|
||||
if old_hi != new_hi || !s:hl_group_exists(a:group)
|
||||
let cmd = printf('hi %s %s %s %s %s %s %s %s',
|
||||
\ a:group, s:Get(colors, 0, 'guifg=', ''), s:Get(colors, 1, 'guibg=', ''),
|
||||
\ s:Get(colors, 2, 'ctermfg=', ''), s:Get(colors, 3, 'ctermbg=', ''),
|
||||
\ s:Get(colors, 4, 'gui=', ''), s:Get(colors, 4, 'cterm=', ''),
|
||||
\ s:Get(colors, 4, 'term=', ''))
|
||||
\ a:group, s:Get(colors, 0, 'guifg='), s:Get(colors, 1, 'guibg='),
|
||||
\ s:Get(colors, 2, 'ctermfg='), s:Get(colors, 3, 'ctermbg='),
|
||||
\ s:Get(colors, 4, 'gui='), s:Get(colors, 4, 'cterm='),
|
||||
\ s:Get(colors, 4, 'term='))
|
||||
exe cmd
|
||||
endif
|
||||
endfunction
|
||||
|
@ -132,11 +132,12 @@ function! s:CheckDefined(colors)
|
|||
return a:colors[0:1] + [fg, bg] + [a:colors[4]]
|
||||
endfunction
|
||||
|
||||
function! s:Get(dict, key, prefix, default)
|
||||
if get(a:dict, a:key, a:default) isnot# a:default
|
||||
return a:prefix. get(a:dict, a:key)
|
||||
else
|
||||
function! s:Get(dict, key, prefix)
|
||||
let res=get(a:dict, a:key, '')
|
||||
if empty(res)
|
||||
return ''
|
||||
else
|
||||
return a:prefix. res
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
|
Loading…
Reference in New Issue