From 6ebf296e9f8d41895d304d8c1a95b6ee1900fda1 Mon Sep 17 00:00:00 2001 From: Webster Sheets Date: Wed, 16 Oct 2024 16:44:15 -0400 Subject: [PATCH] refactor: remove manual rate-limiting in saveloadgame.lua - Prior code limited synchronous Game.SaveGameStats calls to once-per-frame - Since the function is now async, we can dispatch as many jobs as we want and their results will be processed on completion --- data/pigui/modules/saveloadgame.lua | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/data/pigui/modules/saveloadgame.lua b/data/pigui/modules/saveloadgame.lua index 94e93fef5c..0af3c23d0a 100644 --- a/data/pigui/modules/saveloadgame.lua +++ b/data/pigui/modules/saveloadgame.lua @@ -300,6 +300,13 @@ function SaveLoadWindow:makeFileList() return a.mtime.timestamp > b.mtime.timestamp end) + -- Cache details about each savefile + for _, file in ipairs(self.files) do + if not self.entryCache[file.name] or self.entryCache[file.name].timestamp ~= file.mtime.timestamp then + self.entryCache[file.name] = makeEntryForSave(file) + end + end + self:makeFilteredList() -- profileEndScope() end @@ -351,21 +358,6 @@ function SaveLoadWindow:deleteSelectedSave() end) end -function SaveLoadWindow:update() - ModalWindow.update(self) - - -- Incrementally update cache until all files are up to date - -- We don't need to manually clear the cache, as changes to the list of - -- files will trigger the cache to be updated - local uncached = utils.find_if(self.files, function(_, file) - return not self.entryCache[file.name] or self.entryCache[file.name].timestamp ~= file.mtime.timestamp - end) - - if uncached then - self.entryCache[uncached.name] = makeEntryForSave(uncached) - end -end - --============================================================================= function SaveLoadWindow:onOpen()