mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
GameInfoCache: Move some I/O out of the mutex. There's more to do.
This commit is contained in:
parent
71354d0189
commit
e29f59a102
1 changed files with 10 additions and 6 deletions
|
@ -340,16 +340,19 @@ static bool ReadFileToString(IFileSystem *fs, const char *filename, std::string
|
|||
if (handle < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mtx) {
|
||||
std::string data;
|
||||
data.resize(info.size);
|
||||
fs->ReadFile(handle, (u8 *)data.data(), info.size);
|
||||
fs->CloseFile(handle);
|
||||
|
||||
std::lock_guard<std::mutex> lock(*mtx);
|
||||
contents->resize(info.size);
|
||||
fs->ReadFile(handle, (u8 *)contents->data(), info.size);
|
||||
*contents = std::move(data);
|
||||
} else {
|
||||
contents->resize(info.size);
|
||||
fs->ReadFile(handle, (u8 *)contents->data(), info.size);
|
||||
fs->CloseFile(handle);
|
||||
}
|
||||
fs->CloseFile(handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -363,12 +366,13 @@ static bool ReadVFSToString(const char *filename, std::string *contents, std::mu
|
|||
} else {
|
||||
*contents = std::string((const char *)data, sz);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
delete [] data;
|
||||
return data != nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
class GameInfoWorkItem : public Task {
|
||||
public:
|
||||
GameInfoWorkItem(const Path &gamePath, std::shared_ptr<GameInfo> &info)
|
||||
|
|
Loading…
Add table
Reference in a new issue