c syntax_checker: major performance improvements

This commit is contained in:
kongo2002 2010-10-19 03:14:49 +08:00 committed by Chris Hoffman
parent 9b66271e39
commit 1473b7dcdb

View File

@ -98,10 +98,10 @@ function! SyntaxCheckers_c_GetLocList()
\ g:syntastic_c_no_include_search != 1
if exists('g:syntastic_c_auto_refresh_includes') &&
\ g:syntastic_c_auto_refresh_includes != 0
let makeprg .= s:SearchHeaders(s:handlers)
let makeprg .= s:SearchHeaders()
else
if !exists('b:syntastic_c_includes')
let b:syntastic_c_includes = s:SearchHeaders(s:handlers)
let b:syntastic_c_includes = s:SearchHeaders()
endif
let makeprg .= b:syntastic_c_includes
endif
@ -115,20 +115,24 @@ endfunction
" search the first 100 lines for include statements that are
" given in the s:handlers dictionary
function! s:SearchHeaders(handlers)
function! s:SearchHeaders()
let includes = ''
let l:handlers = copy(a:handlers)
let files = []
let found = []
let lines = filter(getline(1, 100), 'v:val =~# "#\s*include"')
" search current buffer
for i in range(100)
for handler in l:handlers
let line = getline(i)
if line =~# '^#include.*' . handler["regex"]
for line in lines
let file = matchstr(line, '"\zs\S\+\ze"')
if file != ''
call add(files, file)
continue
endif
for handler in s:handlers
if line =~# handler["regex"]
let includes .= call(handler["func"], handler["args"])
call remove(l:handlers, index(l:handlers, handler))
elseif line =~# '^#include\s\+"\S\+"'
call add(files, matchstr(line, '^#include\s\+"\zs\S\+\ze"'))
call add(found, handler["regex"])
break
endif
endfor
endfor
@ -143,11 +147,16 @@ function! s:SearchHeaders(handlers)
catch /E484/
continue
endtry
for line in lines
for handler in l:handlers
if line =~# '^#include.*' . handler["regex"]
let lines = filter(lines, 'v:val =~# "#\s*include"')
for handler in s:handlers
if index(found, handler["regex"]) != -1
continue
endif
for line in lines
if line =~# handler["regex"]
let includes .= call(handler["func"], handler["args"])
call remove(l:handlers, index(l:handlers, handler))
call add(found, handler["regex"])
break
endif
endfor
endfor