From 82ea36576c2221dc20ca98b748d7c83a25f9a4d3 Mon Sep 17 00:00:00 2001 From: w0rp Date: Tue, 19 Jun 2018 20:53:49 +0100 Subject: Move ClockMilliseconds to events, so fewer files are loaded some times --- autoload/ale.vim | 2 +- autoload/ale/engine.vim | 6 +++--- autoload/ale/events.vim | 14 ++++++++++++-- autoload/ale/util.vim | 10 ---------- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'autoload') 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 " 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(). -- cgit v1.2.3