[vlc-devel] [PATCH 5/5] VLSub: Preserve table ordering

Alon Sirota sirotaalon at gmail.com
Sun Sep 6 09:39:35 CEST 2020


Replace pairs with ipairs, in 'find_subtitle_in_archive' and in
'download_subtitles'.

In both table iterations, keys should be integers, so we can use ipairs
which will make sure the ordering will be perserved.
---
 share/lua/extensions/VLSub.lua | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/share/lua/extensions/VLSub.lua b/share/lua/extensions/VLSub.lua
index 10400cf..dc166fe 100644
--- a/share/lua/extensions/VLSub.lua
+++ b/share/lua/extensions/VLSub.lua
@@ -1445,7 +1445,7 @@ function find_subtitle_in_archive(archivePath, subfileExt)
     return nil
   end
   subfileExt = "." .. subfileExt
-  for _, item in pairs(items) do
+  for _, item in ipairs(items) do
     if string.sub(item:uri(), -string.len(subfileExt)) == subfileExt then
       return item:uri()
     end
@@ -1463,7 +1463,7 @@ function download_subtitles()
 
   display_subtitles() -- reset selection
 
-  for _, index in pairs(indexes) do
+  for _, index in ipairs(indexes) do
     item = openSub.itemStore[index]
 
   if openSub.option.downloadBehaviour == 'manual'
-- 
2.28.0



More information about the vlc-devel mailing list