@@ -153,7 +153,7 @@ local function update_tracks_menu(menu)
153153 local function track_list_cb (_ , track_list )
154154 for i = # submenu , 1 , - 1 do table.remove (submenu , i ) end
155155 menu_items_dirty = true
156- if not track_list or next ( track_list ) == nil then return end
156+ if not track_list or # track_list == 0 then return end
157157
158158 local items_v = build_track_items (track_list , ' video' , ' vid' , true )
159159 local items_a = build_track_items (track_list , ' audio' , ' aid' , true )
@@ -177,7 +177,7 @@ local function update_track_menu(menu, type, prop)
177177 local function track_list_cb (_ , track_list )
178178 for i = # submenu , 1 , - 1 do table.remove (submenu , i ) end
179179 menu_items_dirty = true
180- if not track_list or next ( track_list ) == nil then return end
180+ if not track_list or # track_list == 0 then return end
181181
182182 local items = build_track_items (track_list , type , prop , false )
183183 for _ , item in ipairs (items ) do table.insert (submenu , item ) end
@@ -193,7 +193,7 @@ local function update_chapters_menu(menu)
193193 local function chapter_list_cb (_ , chapter_list )
194194 for i = # submenu , 1 , - 1 do table.remove (submenu , i ) end
195195 menu_items_dirty = true
196- if not chapter_list or next ( chapter_list ) == nil then return end
196+ if not chapter_list or # chapter_list == 0 then return end
197197
198198 local pos = mp .get_property_number (' chapter' , - 1 )
199199 for id , chapter in ipairs (chapter_list ) do
@@ -228,7 +228,7 @@ local function update_editions_menu(menu)
228228 local function edition_list_cb (_ , edition_list )
229229 for i = # submenu , 1 , - 1 do table.remove (submenu , i ) end
230230 menu_items_dirty = true
231- if not edition_list or next ( edition_list ) == nil then return end
231+ if not edition_list or # edition_list == 0 then return end
232232
233233 local current = mp .get_property_number (' current-edition' , - 1 )
234234 for id , edition in ipairs (edition_list ) do
@@ -262,7 +262,7 @@ local function update_audio_devices_menu(menu)
262262 local function device_list_cb (_ , device_list )
263263 for i = # submenu , 1 , - 1 do table.remove (submenu , i ) end
264264 menu_items_dirty = true
265- if not device_list or next ( device_list ) == nil then return end
265+ if not device_list or # device_list == 0 then return end
266266
267267 local current = mp .get_property (' audio-device' , ' ' )
268268 for _ , device in ipairs (device_list ) do
@@ -307,7 +307,7 @@ local function update_playlist_menu(menu)
307307 local function playlist_cb (_ , playlist )
308308 for i = # submenu , 1 , - 1 do table.remove (submenu , i ) end
309309 menu_items_dirty = true
310- if not playlist or next ( playlist ) == nil then return end
310+ if not playlist or # playlist == 0 then return end
311311
312312 for id , item in ipairs (playlist ) do
313313 submenu [# submenu + 1 ] = {
@@ -328,7 +328,7 @@ local function update_profiles_menu(menu)
328328 local function profile_list_cb (_ , profile_list )
329329 for i = # submenu , 1 , - 1 do table.remove (submenu , i ) end
330330 menu_items_dirty = true
331- if not profile_list or next ( profile_list ) == nil then return end
331+ if not profile_list or # profile_list == 0 then return end
332332
333333 for _ , profile in ipairs (profile_list ) do
334334 if not (profile .name == ' default' or profile .name :find (' gui' ) or
@@ -355,7 +355,7 @@ function update_check_status(menu, keyword)
355355 if tp == ' boolean' then return v end
356356 if tp == ' string' then return v ~= ' ' end
357357 if tp == ' number' then return v ~= 0 end
358- if tp == ' table' then return # v > 0 end
358+ if tp == ' table' then return next ( v ) ~= nil end
359359 return v ~= nil
360360 end
361361
431431
432432-- menu data update callback
433433local function menu_data_cb (name , items )
434- if not items or next ( items ) == nil then return end
434+ if not items or # items == 0 then return end
435435 mp .unobserve_property (menu_data_cb )
436436
437437 menu_items = items
0 commit comments