1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-21 05:53:02 +01:00

Add File::GetSize to get object size in a simpler way

Drastically reduces startup speed because of the
optimization applied to ObjectAsset::GetSize - now the file
size is obtained without reading the entire file into memory.
This commit is contained in:
Silent
2021-05-21 16:55:07 +02:00
parent dc11021192
commit 95388cfbb1
8 changed files with 46 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
/*****************************************************************************
* Copyright (c) 2014-2020 OpenRCT2 developers
* Copyright (c) 2014-2021 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
@@ -252,18 +252,11 @@ bool ObjectAsset::IsAvailable() const
}
}
size_t ObjectAsset::GetSize() const
uint64_t ObjectAsset::GetSize() const
{
if (_zipPath.empty())
{
try
{
return File::ReadAllBytes(_path).size();
}
catch (...)
{
return 0;
}
return File::GetSize(_path);
}
else
{