Experimentally add priority run when scanning project files

Avoid yielding when a first scan is required but seems quite
ineffective.
This commit is contained in:
Francesco Abbate 2020-12-08 16:59:05 +01:00
parent e88adc0567
commit f882957ebc
1 changed files with 5 additions and 1 deletions

View File

@ -55,6 +55,8 @@ function core.open_folder_project(dirname)
end end
local function project_scan_thread() local function project_scan_thread()
local priority_run = true
local function diff_files(a, b) local function diff_files(a, b)
if #a ~= #b then return true end if #a ~= #b then return true end
for i, v in ipairs(a) do for i, v in ipairs(a) do
@ -70,7 +72,7 @@ local function project_scan_thread()
end end
local function get_files(path, t) local function get_files(path, t)
coroutine.yield() if not priority_run then coroutine.yield() end
t = t or {} t = t or {}
local size_limit = config.file_size_limit * 10e5 local size_limit = config.file_size_limit * 10e5
local all = system.list_dir(path) or {} local all = system.list_dir(path) or {}
@ -120,11 +122,13 @@ local function project_scan_thread()
end end
core.project_files = t core.project_files = t
core.redraw = true core.redraw = true
priority_run = false
end end
-- wait for next scan -- wait for next scan
if core.switch_project then if core.switch_project then
system.chdir(core.switch_project) system.chdir(core.switch_project)
priority_run = true
core.switch_project = nil core.switch_project = nil
else else
coroutine.yield(config.project_scan_rate) coroutine.yield(config.project_scan_rate)