Optimise loclist.filter().
This commit is contained in:
parent
ee3c56c6f7
commit
327ba4c415
@ -126,22 +126,10 @@ endfunction
|
||||
"
|
||||
"Note that all comparisons are done with ==?
|
||||
function! g:SyntasticLoclist.filter(filters)
|
||||
let rv = []
|
||||
|
||||
for error in self._rawLoclist
|
||||
let passes_filters = 1
|
||||
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
|
||||
let conditions = values(map(copy(a:filters), 's:translate(v:key, v:val)'))
|
||||
let filter = len(conditions) == 1 ?
|
||||
\ conditions[0] : join(map(conditions, '"(" . v:val . ")"'), ' && ')
|
||||
return filter(copy(self._rawLoclist), filter)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticLoclist.setloclist()
|
||||
@ -192,4 +180,10 @@ function! g:SyntasticLoclistHide()
|
||||
silent! lclose
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user