Handling redefinition of exec: minor optimisation.

This commit is contained in:
LCD 47 2015-02-22 18:50:10 +02:00
parent 8256e43510
commit bccfdea4e8
2 changed files with 23 additions and 19 deletions

View File

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START lockvar! g:_SYNTASTIC_START
endif endif
let g:_SYNTASTIC_VERSION = '3.6.0-32' let g:_SYNTASTIC_VERSION = '3.6.0-33'
lockvar g:_SYNTASTIC_VERSION lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1 " Sanity checks {{{1

View File

@ -48,13 +48,32 @@ function! g:SyntasticChecker.getName() " {{{2
return self._name return self._name
endfunction " }}}2 endfunction " }}}2
" Synchronise _exec with user's setting. Force re-validation if needed.
"
" XXX: This function must be called at least once before calling either
" getExec() or getExecEscaped(). Normally isAvailable() does that for you
" automatically, but you should keep still this in mind if you change the
" current checker workflow.
function! g:SyntasticChecker.syncExec() dict " {{{2
let user_exec =
\ expand( exists('b:syntastic_' . self._name . '_exec') ? b:syntastic_{self._name}_exec :
\ syntastic#util#var(self._filetype . '_' . self._name . '_exec'), 1 )
if user_exec != '' && user_exec !=# self._exec
let self._exec = user_exec
if has_key(self, '_available')
" we have a new _exec on the block, it has to be validated
call remove(self, '_available')
endif
endif
endfunction " }}}2
function! g:SyntasticChecker.getExec() " {{{2 function! g:SyntasticChecker.getExec() " {{{2
call self._syncExec()
return self._exec return self._exec
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker.getExecEscaped() " {{{2 function! g:SyntasticChecker.getExecEscaped() " {{{2
return syntastic#util#shescape(self.getExec()) return syntastic#util#shescape(self._exec)
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker.getLocListRaw() " {{{2 function! g:SyntasticChecker.getLocListRaw() " {{{2
@ -120,7 +139,7 @@ function! g:SyntasticChecker.makeprgBuild(opts) " {{{2
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker.isAvailable() " {{{2 function! g:SyntasticChecker.isAvailable() " {{{2
call self._syncExec() call self.syncExec()
if !has_key(self, '_available') if !has_key(self, '_available')
let self._available = self._isAvailableFunc() let self._available = self._isAvailableFunc()
endif endif
@ -143,21 +162,6 @@ endfunction " }}}2
" Private methods {{{1 " Private methods {{{1
" Synchronise _exec with user's setting. Force re-validation if needed.
function! g:SyntasticChecker._syncExec() dict " {{{2
let user_exec =
\ expand( exists('b:syntastic_' . self._name . '_exec') ? b:syntastic_{self._name}_exec :
\ syntastic#util#var(self._filetype . '_' . self._name . '_exec'), 1 )
if user_exec != '' && user_exec !=# self._exec
let self._exec = user_exec
if has_key(self, '_available')
" we have a new _exec on the block, it has to be validated
call remove(self, '_available')
endif
endif
endfunction " }}}2
function! g:SyntasticChecker._quietMessages(errors) " {{{2 function! g:SyntasticChecker._quietMessages(errors) " {{{2
" wildcard quiet_messages " wildcard quiet_messages
let quiet_filters = copy(syntastic#util#var('quiet_messages', {})) let quiet_filters = copy(syntastic#util#var('quiet_messages', {}))