1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-21 01:27:14 +02:00

Avoid creating multiple objects for the same string when event parameters contain strings.

Include a helper fonstructor in the light object type for quick string object creation.
This commit is contained in:
Sandu Liviu Catalin
2017-02-21 22:17:25 +02:00
parent 135484e467
commit c5b509dcb3
2 changed files with 35 additions and 11 deletions

View File

@ -711,6 +711,24 @@ struct LightObj {
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Constructs a LightObj from a string
///
/// \param i The string itself
/// \param i The length of the string
/// \param v VM that the object will exist in
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
LightObj(const SQChar * s, SQInteger l, HSQUIRRELVM v = DefaultVM::Get()) {
sq_pushstring(v, s, l);
if (SQ_FAILED(sq_getstackobj(v, -1, &mObj))) {
sq_resetobject(&mObj);
} else {
sq_addref(v, &mObj);
}
sq_pop(v, 1);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Construct a LightObj from a regular Object instance.
///