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:
Campbell Barton
2009-02-19 13:42:07 +00:00
parent c597863783
commit cdec2b3d15
127 changed files with 392 additions and 403 deletions

View File

@@ -142,23 +142,21 @@ PyParentObject KX_PhysicsObjectWrapper::Parents[] = {
NULL
};
PyObject* KX_PhysicsObjectWrapper::_getattr(const STR_String& attr)
PyObject* KX_PhysicsObjectWrapper::_getattr(const char *attr)
{
_getattr_up(PyObjectPlus);
}
int KX_PhysicsObjectWrapper::_setattr(const STR_String& attr,PyObject* pyobj)
int KX_PhysicsObjectWrapper::_setattr(const char *attr,PyObject *pyobj)
{
PyTypeObject* type = pyobj->ob_type;
int result = 1;
if (type == &PyInt_Type)
if (PyInt_Check(pyobj))
{
result = 0;
}
if (type == &PyString_Type)
if (PyString_Check(pyobj))
{
result = 0;
}