Optimise loclist.filter().
This commit is contained in:
parent
ee3c56c6f7
commit
327ba4c415
@ -126,22 +126,10 @@ endfunction
|
|||||||
"
|
"
|
||||||
"Note that all comparisons are done with ==?
|
"Note that all comparisons are done with ==?
|
||||||
function! g:SyntasticLoclist.filter(filters)
|
function! g:SyntasticLoclist.filter(filters)
|
||||||
let rv = []
|
let conditions = values(map(copy(a:filters), 's:translate(v:key, v:val)'))
|
||||||
|
let filter = len(conditions) == 1 ?
|
||||||
for error in self._rawLoclist
|
\ conditions[0] : join(map(conditions, '"(" . v:val . ")"'), ' && ')
|
||||||
let passes_filters = 1
|
return filter(copy(self._rawLoclist), filter)
|
||||||
for key in keys(a:filters)
|
|
||||||
if get(error, key, '') !=? a:filters[key]
|
|
||||||
let passes_filters = 0
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
if passes_filters
|
|
||||||
call add(rv, error)
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
return rv
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! g:SyntasticLoclist.setloclist()
|
function! g:SyntasticLoclist.setloclist()
|
||||||
@ -192,4 +180,10 @@ function! g:SyntasticLoclistHide()
|
|||||||
silent! lclose
|
silent! lclose
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Private functions {{{1
|
||||||
|
|
||||||
|
function! s:translate(key, val)
|
||||||
|
return 'get(v:val, ' . string(a:key) . ', "") ==? ' . string(a:val)
|
||||||
|
endfunction
|
||||||
|
|
||||||
" vim: set sw=4 sts=4 et fdm=marker:
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
|
Loading…
Reference in New Issue
Block a user