diff options
author | w0rp <devw0rp@gmail.com> | 2018-06-19 20:53:49 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2018-06-19 20:53:49 +0100 |
commit | 82ea36576c2221dc20ca98b748d7c83a25f9a4d3 (patch) | |
tree | 8d9ff51912934475f8a0fa84674f2ce90a7bb7b4 /autoload | |
parent | fd261d7a171686a395b0c31cbc1c97e24cf24290 (diff) | |
download | ale-82ea36576c2221dc20ca98b748d7c83a25f9a4d3.zip |
Move ClockMilliseconds to events, so fewer files are loaded some times
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale.vim | 2 | ||||
-rw-r--r-- | autoload/ale/engine.vim | 6 | ||||
-rw-r--r-- | autoload/ale/events.vim | 14 | ||||
-rw-r--r-- | autoload/ale/util.vim | 10 |
4 files changed, 16 insertions, 16 deletions
diff --git a/autoload/ale.vim b/autoload/ale.vim index f31446cb..859bb5b8 100644 --- a/autoload/ale.vim +++ b/autoload/ale.vim @@ -21,7 +21,7 @@ let s:timestamp_map = {} " If the function throws an exception, then the function will not be called " for a while, and 0 will be returned instead. function! ale#CallWithCooldown(timestamp_key, func, arglist) abort - let l:now = ale#util#ClockMilliseconds() + let l:now = ale#events#ClockMilliseconds() if l:now < get(s:timestamp_map, a:timestamp_key, -1) return 0 diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim index 563c37a2..714c75b1 100644 --- a/autoload/ale/engine.vim +++ b/autoload/ale/engine.vim @@ -779,7 +779,7 @@ endfunction " The time taken will be a very rough approximation, and more time may be " permitted than is specified. function! ale#engine#WaitForJobs(deadline) abort - let l:start_time = ale#util#ClockMilliseconds() + let l:start_time = ale#events#ClockMilliseconds() if l:start_time == 0 throw 'Failed to read milliseconds from the clock!' @@ -810,7 +810,7 @@ function! ale#engine#WaitForJobs(deadline) abort for l:job_id in l:job_list if ale#job#IsRunning(l:job_id) - let l:now = ale#util#ClockMilliseconds() + let l:now = ale#events#ClockMilliseconds() if l:now - l:start_time > a:deadline " Stop waiting after a timeout, so we don't wait forever. @@ -847,7 +847,7 @@ function! ale#engine#WaitForJobs(deadline) abort if l:has_new_jobs " We have to wait more. Offset the timeout by the time taken so far. - let l:now = ale#util#ClockMilliseconds() + let l:now = ale#events#ClockMilliseconds() let l:new_deadline = a:deadline - (l:now - l:start_time) if l:new_deadline <= 0 diff --git a/autoload/ale/events.vim b/autoload/ale/events.vim index a12ca049..7cdc2e8e 100644 --- a/autoload/ale/events.vim +++ b/autoload/ale/events.vim @@ -1,15 +1,25 @@ " Author: w0rp <devw0rp@gmail.com> " Description: ALE functions for autocmd events. +" Get the number of milliseconds since some vague, but consistent, point in +" the past. +" +" This function can be used for timing execution, etc. +" +" The time will be returned as a Number. +function! ale#events#ClockMilliseconds() abort + return float2nr(reltimefloat(reltime()) * 1000) +endfunction + function! ale#events#QuitEvent(buffer) abort " Remember when ALE is quitting for BufWrite, etc. - call setbufvar(a:buffer, 'ale_quitting', ale#util#ClockMilliseconds()) + call setbufvar(a:buffer, 'ale_quitting', ale#events#ClockMilliseconds()) endfunction function! ale#events#QuitRecently(buffer) abort let l:time = getbufvar(a:buffer, 'ale_quitting', 0) - return l:time && ale#util#ClockMilliseconds() - l:time < 1000 + return l:time && ale#events#ClockMilliseconds() - l:time < 1000 endfunction function! ale#events#SaveEvent(buffer) abort diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim index 4e789b72..c01b6dd0 100644 --- a/autoload/ale/util.vim +++ b/autoload/ale/util.vim @@ -241,16 +241,6 @@ function! ale#util#InSandbox() abort return 0 endfunction -" Get the number of milliseconds since some vague, but consistent, point in -" the past. -" -" This function can be used for timing execution, etc. -" -" The time will be returned as a Number. -function! ale#util#ClockMilliseconds() abort - return float2nr(reltimefloat(reltime()) * 1000) -endfunction - " Given a single line, or a List of lines, and a single pattern, or a List " of patterns, return all of the matches for the lines(s) from the given " patterns, using matchlist(). |