Optimize FindObject and TryFindObject in Object

This commit is contained in:
Wojtek Figat
2021-08-10 15:57:22 +02:00
parent 62c43f9f95
commit 27f2856e6d
4 changed files with 39 additions and 9 deletions

View File

@@ -62,7 +62,6 @@ public:
/// <summary>
/// Gets the managed instance object.
/// </summary>
/// <returns>The Mono managed object or null if not created.</returns>
MonoObject* GetManagedInstance() const;
/// <summary>
@@ -131,6 +130,7 @@ public:
/// <param name="to">The destination class to the cast.</param>
/// <returns>True if can, otherwise false.</returns>
static bool CanCast(MClass* from, MClass* to);
static bool CanCast(MClass* from, MonoClass* to);
template<typename T>
static T* Cast(ScriptingObject* obj)
@@ -145,6 +145,11 @@ public:
return CanCast(GetClass(), type);
}
bool Is(MonoClass* klass) const
{
return CanCast(GetClass(), klass);
}
template<typename T>
bool Is() const
{