BGE Python API
Use 'const char *' rather then the C++ 'STR_String' type for the attribute identifier of python attributes. Each attribute and method access from python was allocating and freeing the string. A simple test with getting an attribute a loop shows this speeds up attribute lookups a bit over 2x.
This commit is contained in:
@@ -341,7 +341,7 @@ PyAttributeDef SCA_MouseSensor::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* SCA_MouseSensor::_getattr(const STR_String& attr)
|
||||
PyObject* SCA_MouseSensor::_getattr(const char *attr)
|
||||
{
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
@@ -349,7 +349,7 @@ PyObject* SCA_MouseSensor::_getattr(const STR_String& attr)
|
||||
_getattr_up(SCA_ISensor);
|
||||
}
|
||||
|
||||
int SCA_MouseSensor::_setattr(const STR_String& attr, PyObject *value)
|
||||
int SCA_MouseSensor::_setattr(const char *attr, PyObject *value)
|
||||
{
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
|
||||
Reference in New Issue
Block a user