Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-02-19 16:42:07 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-02-19 16:42:07 +0300
commitcdec2b3d15ab0448e4df70496285ed95681e5972 (patch)
treef6d2d49a28c45d035c0c047c9488d687a75d459b /source/gameengine/Expressions/PyObjectPlus.cpp
parentc597863783e1001dca599e6dcbc28048f0ef4ce1 (diff)
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.
Diffstat (limited to 'source/gameengine/Expressions/PyObjectPlus.cpp')
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp
index 19f458b69a6..16184b7c5f2 100644
--- a/source/gameengine/Expressions/PyObjectPlus.cpp
+++ b/source/gameengine/Expressions/PyObjectPlus.cpp
@@ -106,24 +106,24 @@ PyParentObject PyObjectPlus::Parents[] = {&PyObjectPlus::Type, NULL};
/*------------------------------
* PyObjectPlus attributes -- attributes
------------------------------*/
-PyObject *PyObjectPlus::_getattr(const STR_String& attr)
+PyObject *PyObjectPlus::_getattr(const char *attr)
{
- if (attr == "__doc__" && GetType()->tp_doc)
+ if (!strcmp(attr, "__doc__") && GetType()->tp_doc)
return PyString_FromString(GetType()->tp_doc);
//if (streq(attr, "type"))
// return Py_BuildValue("s", (*(GetParents()))->tp_name);
- return Py_FindMethod(Methods, this, const_cast<char *>(attr.ReadPtr()));
+ return Py_FindMethod(Methods, this, attr);
}
-int PyObjectPlus::_delattr(const STR_String& attr)
+int PyObjectPlus::_delattr(const char *attr)
{
PyErr_SetString(PyExc_AttributeError, "attribute cant be deleted");
return 1;
}
-int PyObjectPlus::_setattr(const STR_String& attr, PyObject *value)
+int PyObjectPlus::_setattr(const char *attr, PyObject *value)
{
//return PyObject::_setattr(attr,value);
//cerr << "Unknown attribute" << endl;
@@ -131,12 +131,12 @@ int PyObjectPlus::_setattr(const STR_String& attr, PyObject *value)
return 1;
}
-PyObject *PyObjectPlus::_getattr_self(const PyAttributeDef attrlist[], void *self, const STR_String &attr)
+PyObject *PyObjectPlus::_getattr_self(const PyAttributeDef attrlist[], void *self, const char *attr)
{
const PyAttributeDef *attrdef;
for (attrdef=attrlist; attrdef->m_name != NULL; attrdef++)
{
- if (attr == attrdef->m_name)
+ if (!strcmp(attr, attrdef->m_name))
{
if (attrdef->m_type == KX_PYATTRIBUTE_TYPE_DUMMY)
{
@@ -238,7 +238,7 @@ PyObject *PyObjectPlus::_getattr_self(const PyAttributeDef attrlist[], void *sel
return NULL;
}
-int PyObjectPlus::_setattr_self(const PyAttributeDef attrlist[], void *self, const STR_String &attr, PyObject *value)
+int PyObjectPlus::_setattr_self(const PyAttributeDef attrlist[], void *self, const char *attr, PyObject *value)
{
const PyAttributeDef *attrdef;
void *undoBuffer = NULL;
@@ -247,7 +247,7 @@ int PyObjectPlus::_setattr_self(const PyAttributeDef attrlist[], void *self, con
for (attrdef=attrlist; attrdef->m_name != NULL; attrdef++)
{
- if (attr == attrdef->m_name)
+ if (!strcmp(attr, attrdef->m_name))
{
if (attrdef->m_access == KX_PYATTRIBUTE_RO ||
attrdef->m_type == KX_PYATTRIBUTE_TYPE_DUMMY)