1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 08:47:17 +01:00

Further optimize instance retrieval.

More risky changes but the current constraints should allow it.
This commit is contained in:
Sandu Liviu Catalin 2021-01-30 19:59:34 +02:00
parent b0bbb05631
commit bb991181de
2 changed files with 5 additions and 4 deletions

View File

@ -90,7 +90,7 @@ public:
sq_push(v, -2);
sq_rawset(v, -4);
}
sq_pushstring(v, className.c_str(), -1);
sq_pushstring(v, className.c_str(), static_cast<SQInteger>(className.size()));
auto** ud = reinterpret_cast<ClassData<C>**>(sq_newuserdata(v, sizeof(ClassData<C>*)));
*ud = new ClassData<C>;
sq_setreleasehook(v, -1, &cleanup_hook);

View File

@ -237,16 +237,17 @@ public:
}
static C* GetInstance(HSQUIRRELVM vm, SQInteger idx, bool nullAllowed = false) {
AbstractStaticClassData* classType = nullptr;
//AbstractStaticClassData* classType = nullptr;
AbstractStaticClassData* classType = StaticClassTypeTag<C>::Get();
std::pair<C*, SharedPtr<std::unordered_map<C*, HSQOBJECT>> >* instance = nullptr;
if (hasClassData(vm)) /* type checking only done if the value has type data else it may be enum */
//if (hasClassData(vm)) /* type checking only done if the value has type data else it may be enum */
if (classType!=nullptr) /* type checking only done if the value has type data else it may be enum */
{
if (nullAllowed && sq_gettype(vm, idx) == OT_NULL) {
return nullptr;
}
//classType = getStaticClassData().Lock().Get();
classType = StaticClassTypeTag<C>::Get();
#if !defined (SCRAT_NO_ERROR_CHECKING)
if (SQ_FAILED(sq_getinstanceup(vm, idx, (SQUserPointer*)&instance, classType))) {