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:
@ -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.
|
||||
///
|
||||
|
Reference in New Issue
Block a user