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/Ketsji/KX_PolyProxy.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/Ketsji/KX_PolyProxy.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_PolyProxy.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp
index bb9072b34dc..1c9e2a49c11 100644
--- a/source/gameengine/Ketsji/KX_PolyProxy.cpp
+++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp
@@ -77,18 +77,17 @@ PyMethodDef KX_PolyProxy::Methods[] = {
{NULL,NULL} //Sentinel
};
-PyObject*
-KX_PolyProxy::_getattr(const STR_String& attr)
+PyObject* KX_PolyProxy::_getattr(const char *attr)
{
- if (attr == "matname")
+ if (!strcmp(attr, "matname"))
{
return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
}
- if (attr == "texture")
+ if (!strcmp(attr, "texture"))
{
return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
}
- if (attr == "material")
+ if (!strcmp(attr, "material"))
{
RAS_IPolyMaterial *polymat = m_polygon->GetMaterial()->GetPolyMaterial();
if(polymat->GetFlag() & RAS_BLENDERMAT)
@@ -104,7 +103,7 @@ KX_PolyProxy::_getattr(const STR_String& attr)
return mat;
}
}
- if (attr == "matid")
+ if (!strcmp(attr, "matid"))
{
// we'll have to scan through the material bucket of the mes and compare with
// the one of the polygon
@@ -119,27 +118,27 @@ KX_PolyProxy::_getattr(const STR_String& attr)
}
return PyInt_FromLong(matid);
}
- if (attr == "v1")
+ if (!strcmp(attr, "v1"))
{
return PyInt_FromLong(m_polygon->GetVertexOffset(0));
}
- if (attr == "v2")
+ if (!strcmp(attr, "v2"))
{
return PyInt_FromLong(m_polygon->GetVertexOffset(1));
}
- if (attr == "v3")
+ if (!strcmp(attr, "v3"))
{
return PyInt_FromLong(m_polygon->GetVertexOffset(2));
}
- if (attr == "v4")
+ if (!strcmp(attr, "v4"))
{
return PyInt_FromLong(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffset(3):0));
}
- if (attr == "visible")
+ if (!strcmp(attr, "visible"))
{
return PyInt_FromLong(m_polygon->IsVisible());
}
- if (attr == "collide")
+ if (!strcmp(attr, "collide"))
{
return PyInt_FromLong(m_polygon->IsCollider());
}