Optimize calling Object.FindObject from C#

This commit is contained in:
Wojtek Figat
2021-08-19 13:05:59 +02:00
parent 39a4dab81f
commit a1bf4819cb
2 changed files with 36 additions and 5 deletions

View File

@@ -763,7 +763,7 @@ ScriptingObject* Scripting::FindObject(Guid id, MClass* type)
// Check if object can be an asset and try to load it
if (!type)
{
result = Content::LoadAsync(id, Asset::GetStaticClass());
result = Content::LoadAsync<Asset>(id);
if (!result)
LOG(Warning, "Unable to find scripting object with ID={0}", id);
return result;
@@ -781,6 +781,10 @@ ScriptingObject* Scripting::FindObject(Guid id, MClass* type)
ScriptingObject* Scripting::TryFindObject(Guid id, MClass* type)
{
if (!id.IsValid())
return nullptr;
PROFILE_CPU();
// Try to map object id
const auto idsMapping = ObjectsLookupIdMapping.Get();
if (idsMapping)