From f583df730d577fe253d1660aa0b6548e5e70ffe1 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Thu, 11 Dec 2014 08:32:33 +0200 Subject: [PATCH] Minor optimisation. --- plugin/syntastic.vim | 2 +- plugin/syntastic/loclist.vim | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index 0260b00a..70d5482e 100644 --- a/plugin/syntastic.vim +++ b/plugin/syntastic.vim @@ -305,7 +305,7 @@ function! s:UpdateErrors(auto_invoked, checker_names) " {{{2 " populate loclist and jump {{{3 let do_jump = syntastic#util#var('auto_jump') + 0 if do_jump == 2 - let do_jump = loclist.getFirstError() == 1 + let do_jump = loclist.getFirstError(1) elseif do_jump == 3 let do_jump = loclist.getFirstError() elseif 0 > do_jump || do_jump > 3 diff --git a/plugin/syntastic/loclist.vim b/plugin/syntastic/loclist.vim index 60049270..ced93578 100644 --- a/plugin/syntastic/loclist.vim +++ b/plugin/syntastic/loclist.vim @@ -133,8 +133,13 @@ function! g:SyntasticLoclist.getStatuslineFlag() " {{{2 return self._stl_flag endfunction " }}}2 -function! g:SyntasticLoclist.getFirstError() " {{{2 - for idx in range(len(self._rawLoclist)) +function! g:SyntasticLoclist.getFirstError(...) " {{{2 + let max_issues = len(self._rawLoclist) + if a:0 && a:1 < max_issues + let max_issues = a:1 + endif + + for idx in range(max_issues) if get(self._rawLoclist[idx], 'type', '') ==? 'E' return idx + 1 endif