mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Directly nil check the first element of an array instead of the array's
size when we're only concerned with this single element.
This commit is contained in:
@@ -88,7 +88,7 @@ with anonymous functions.
|
||||
@treturn bool (true if one or more tasks were removed; false otherwise; nil if the task queue is empty).
|
||||
--]]
|
||||
function WakeupMgr:removeTasks(epoch, callback)
|
||||
if #self._task_queue < 1 then return end
|
||||
if #self._task_queue == 0 then return end
|
||||
|
||||
local removed = false
|
||||
local reschedule = false
|
||||
@@ -147,7 +147,7 @@ If necessary, the next upcoming task (if any) is scheduled on exit.
|
||||
@treturn bool (true if we were truly woken up by the scheduled wakeup; false otherwise; nil if there weren't any tasks scheduled).
|
||||
--]]
|
||||
function WakeupMgr:wakeupAction(proximity)
|
||||
if #self._task_queue > 0 then
|
||||
if self._task_queue[1] then
|
||||
local task = self._task_queue[1]
|
||||
if self:validateWakeupAlarmByProximity(task.epoch, proximity) then
|
||||
task.callback()
|
||||
|
||||
@@ -1142,7 +1142,7 @@ end
|
||||
--]]
|
||||
|
||||
function UIManager:getNextTaskTime()
|
||||
if #self._task_queue > 0 then
|
||||
if self._task_queue[1] then
|
||||
return self._task_queue[1].time - time:now()
|
||||
else
|
||||
return nil
|
||||
@@ -1156,10 +1156,12 @@ function UIManager:_checkTasks()
|
||||
-- task.action may schedule other events
|
||||
self._task_queue_dirty = false
|
||||
while true do
|
||||
if #self._task_queue == 0 then
|
||||
if not self._task_queue[1] then
|
||||
-- Nothing to do!
|
||||
break
|
||||
end
|
||||
-- FIXME: Err, the or makes no sense, UIManager:schedule should ensure time & action fields are sane?
|
||||
-- Either check nothing, or check both time *and* action (which should *never* be nil, unless Greminls, c.f., #9112)
|
||||
local task_time = self._task_queue[1].time or 0
|
||||
if task_time <= self._now then
|
||||
-- remove from table
|
||||
|
||||
Reference in New Issue
Block a user