summaryrefslogtreecommitdiff
path: root/autoload/ale/engine.vim
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2018-03-02 12:10:27 +0000
committerw0rp <devw0rp@gmail.com>2018-03-02 12:10:27 +0000
commit2096562899aa0994a2c6d2c30320810001d98591 (patch)
tree28a6697a393ce5952337a05d307685d69e6c59b7 /autoload/ale/engine.vim
parent1d0690f6d774bb736edced967e5eeed7648ff6c1 (diff)
downloadale-2096562899aa0994a2c6d2c30320810001d98591.zip
Make updating linter results slightly faster when the list is empty
Diffstat (limited to 'autoload/ale/engine.vim')
-rw-r--r--autoload/ale/engine.vim26
1 files changed, 15 insertions, 11 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index a21eecdd..9ef3ba39 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -145,35 +145,39 @@ function! s:GatherOutput(job_id, line) abort
endfunction
function! s:HandleLoclist(linter_name, buffer, loclist) abort
- let l:buffer_info = get(g:ale_buffer_info, a:buffer, {})
+ let l:info = get(g:ale_buffer_info, a:buffer, {})
- if empty(l:buffer_info)
+ if empty(l:info)
return
endif
" Remove this linter from the list of active linters.
" This may have already been done when the job exits.
- call filter(l:buffer_info.active_linter_list, 'v:val isnot# a:linter_name')
+ call filter(l:info.active_linter_list, 'v:val isnot# a:linter_name')
" Make some adjustments to the loclists to fix common problems, and also
" to set default values for loclist items.
let l:linter_loclist = ale#engine#FixLocList(a:buffer, a:linter_name, a:loclist)
" Remove previous items for this linter.
- call filter(g:ale_buffer_info[a:buffer].loclist, 'v:val.linter_name isnot# a:linter_name')
- " Add the new items.
- call extend(g:ale_buffer_info[a:buffer].loclist, l:linter_loclist)
+ call filter(l:info.loclist, 'v:val.linter_name isnot# a:linter_name')
- " Sort the loclist again.
- " We need a sorted list so we can run a binary search against it
- " for efficient lookup of the messages in the cursor handler.
- call sort(g:ale_buffer_info[a:buffer].loclist, 'ale#util#LocItemCompare')
+ " We don't need to add items or sort the list when this list is empty.
+ if !empty(l:linter_loclist)
+ " Add the new items.
+ call extend(l:info.loclist, l:linter_loclist)
+
+ " Sort the loclist again.
+ " We need a sorted list so we can run a binary search against it
+ " for efficient lookup of the messages in the cursor handler.
+ call sort(l:info.loclist, 'ale#util#LocItemCompare')
+ endif
if ale#ShouldDoNothing(a:buffer)
return
endif
- call ale#engine#SetResults(a:buffer, g:ale_buffer_info[a:buffer].loclist)
+ call ale#engine#SetResults(a:buffer, l:info.loclist)
endfunction
function! s:HandleExit(job_id, exit_code) abort