From 6dfe65279c75f37348760fad9f75cb49c8a1eb72 Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Sat, 8 Feb 2020 11:45:26 +0100 Subject: [PATCH] [chore] FileChooser: "traditional" for loop for ~15-25% better performance (#5827) Apparently there's less overhead this way. See https://github.com/koreader/koreader/pull/5819 for context. --- frontend/ui/widget/filechooser.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/ui/widget/filechooser.lua b/frontend/ui/widget/filechooser.lua index 36a3c2761..fee16d381 100644 --- a/frontend/ui/widget/filechooser.lua +++ b/frontend/ui/widget/filechooser.lua @@ -242,7 +242,8 @@ function FileChooser:genItemTableFromPath(path) -- otherwise, show new files in bold local show_file_in_bold = G_reader_settings:readSetting("show_file_in_bold") - for _, file in ipairs(files) do + for i = 1, #files do + local file = files[i] local full_path = self.path.."/"..file.name local file_size = lfs.attributes(full_path, "size") or 0 local sstr = getFriendlySize(file_size)