From 7f98c343879b2d578e5c7096a118f51882a4ea8e Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Tue, 27 Jan 2026 01:20:08 -0800 Subject: add caching to EPG metatable --- rt.lua | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'rt.lua') diff --git a/rt.lua b/rt.lua index 3cd79e0..94c665b 100644 --- a/rt.lua +++ b/rt.lua @@ -401,32 +401,24 @@ local menu_option_mt = { end return ret elseif v.epg_channel_id then - if t._info_exp and - osd.redraw_time < - t._info_exp then + local time = osd.redraw_time + if t._exp and time < t._exp then return t._info end local prog = ctx.epg:scheduled_programme( - v.epg_channel_id, - osd.redraw_time) + v.epg_channel_id, time) local ret = prog and prog.title or '' local exp = prog and prog.stop if not prog then prog = ctx.epg:next_programme( - v.epg_channel_id, - osd.redraw_time) + v.epg_channel_id, time) exp = prog and prog.start - - if not prog then - rawset(t, 'info', ret) - return ret - end end - rawset(t, '_info_exp', exp) - rawset(t, '_info', ret) + rawset(t, exp and '_info' or 'info', ret) + rawset(t, '_exp', exp) return ret end end @@ -646,8 +638,17 @@ local epg_programme_mt = { __index = function(t, k) if k == 'active' then local time = osd.redraw_time + if t._exp and time < t._exp then + return t._active + end + local v = t.programme - return time >= v.start and time < v.stop + local ret = time >= v.start and time < v.stop + local exp = time < v.start and v.start or + ret and v.stop or nil + rawset(t, exp and '_active' or 'active', ret) + rawset(t, '_exp', exp) + return ret end end, } -- cgit v1.2.3-70-g09d2