mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-01 13:48:56 +00:00
FileUtil: Add a class for Exists/IsDirectory/GetSize
Some code was calling more than one of these functions in a row (in particular, FileUtil.cpp itself did it a lot...), which is a waste since it's possible to call stat a single time and then read all three values from the stat struct. This commit adds a File::FileInfo class that calls stat once on construction and then lets Exists/IsDirectory/GetSize be executed very quickly. The performance improvement mostly matters for functions that can be handling a lot of files, such as File::ScanDirectoryTree. I've also done some cleanup in code that uses these functions. For instance, some code had checks like !Exists() || !IsDirectory(), which is functionally equivalent to !IsDirectory(), and some code was using File::GetSize even though there was an IOFile object that the code could call GetSize on.
This commit is contained in:
parent
e14a82a87e
commit
5ca3aee00a
21 changed files with 175 additions and 177 deletions
|
@ -56,8 +56,7 @@ void SysConf::Load()
|
|||
{
|
||||
Clear();
|
||||
|
||||
if (!File::Exists(m_file_name) || File::GetSize(m_file_name) != SYSCONF_SIZE ||
|
||||
!LoadFromFile(m_file_name))
|
||||
if (File::GetSize(m_file_name) != SYSCONF_SIZE || !LoadFromFile(m_file_name))
|
||||
{
|
||||
WARN_LOG(CORE, "No valid SYSCONF detected. Creating a new one.");
|
||||
InsertDefaultEntries();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue