From 5d53e59c1d5380c8c3984a191627809c49117a07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 11 Sep 2021 19:33:28 +0200 Subject: [PATCH] Optimize ReadPSPFile (which should probably be replaced with ReadEntireFile anyway) --- Core/Dialog/SavedataParam.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index 22879d326f..3d9b260ee4 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -66,9 +66,12 @@ namespace if (handle < 0) return false; - if(dataSize == -1) - { - dataSize = pspFileSystem.GetFileInfo(filename).size; + if (dataSize == -1) { + // Determine the size through seeking instead of querying. + pspFileSystem.SeekFile(handle, 0, FILEMOVE_END); + dataSize = pspFileSystem.GetSeekPos(handle); + pspFileSystem.SeekFile(handle, 0, FILEMOVE_BEGIN); + *data = new u8[(size_t)dataSize]; }