diff options
Diffstat (limited to 'source/blender/freestyle/intern/python')
-rw-r--r-- | source/blender/freestyle/intern/python/BPy_Operators.cpp | 3 | ||||
-rw-r--r-- | source/blender/freestyle/intern/python/BPy_ViewShape.cpp | 10 | ||||
-rw-r--r-- | source/blender/freestyle/intern/python/Director.cpp | 6 |
3 files changed, 13 insertions, 6 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_Operators.cpp b/source/blender/freestyle/intern/python/BPy_Operators.cpp index d3cb44f5903..57ec15f4150 100644 --- a/source/blender/freestyle/intern/python/BPy_Operators.cpp +++ b/source/blender/freestyle/intern/python/BPy_Operators.cpp @@ -532,8 +532,9 @@ static PyObject *Operators_create(BPy_Operators *self, PyObject *args, PyObject return NULL; } vector<StrokeShader *> shaders; + shaders.reserve(PyList_Size(obj2)); for (int i = 0; i < PyList_Size(obj2); i++) { - PyObject *py_ss = PyList_GetItem(obj2, i); + PyObject *py_ss = PyList_GET_ITEM(obj2, i); if (!BPy_StrokeShader_Check(py_ss)) { PyErr_SetString(PyExc_TypeError, "Operators.create(): 2nd argument must be a list of StrokeShader objects"); return NULL; diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp index 10073204842..6c6e821a1e4 100644 --- a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp +++ b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp @@ -228,8 +228,10 @@ static int ViewShape_vertices_set(BPy_ViewShape *self, PyObject *value, void *UN PyErr_SetString(PyExc_TypeError, "value must be a list of ViewVertex objects"); return -1; } - for (int i = 0; i < PyList_Size(list); i++) { - item = PyList_GetItem(list, i); + + v.reserve(PyList_Size(list)); + for (unsigned int i = 0; i < PyList_Size(list); i++) { + item = PyList_GET_ITEM(list, i); if (BPy_ViewVertex_Check(item)) { v.push_back(((BPy_ViewVertex *)item)->vv); } @@ -270,8 +272,10 @@ static int ViewShape_edges_set(BPy_ViewShape *self, PyObject *value, void *UNUSE PyErr_SetString(PyExc_TypeError, "value must be a list of ViewEdge objects"); return -1; } + + v.reserve(PyList_Size(list)); for (int i = 0; i < PyList_Size(list); i++) { - item = PyList_GetItem(list, i); + item = PyList_GET_ITEM(list, i); if (BPy_ViewEdge_Check(item)) { v.push_back(((BPy_ViewEdge *)item)->ve); } diff --git a/source/blender/freestyle/intern/python/Director.cpp b/source/blender/freestyle/intern/python/Director.cpp index 653fd0b1d29..9f85e84e297 100644 --- a/source/blender/freestyle/intern/python/Director.cpp +++ b/source/blender/freestyle/intern/python/Director.cpp @@ -265,8 +265,9 @@ int Director_BPy_UnaryFunction0D___call__(void *uf0D, void *py_uf0D, Interface0D } else if (BPy_UnaryFunction0DVectorViewShape_Check(obj)) { vector<ViewShape*> vec; + vec.reserve(PyList_Size(result)); for (int i = 0; i < PyList_Size(result); i++) { - ViewShape *b = ((BPy_ViewShape *)PyList_GetItem(result, i))->vs; + ViewShape *b = ((BPy_ViewShape *)PyList_GET_ITEM(result, i))->vs; vec.push_back(b); } ((UnaryFunction0D< vector<ViewShape*> > *)uf0D)->result = vec; @@ -318,8 +319,9 @@ int Director_BPy_UnaryFunction1D___call__(void *uf1D, void *py_uf1D, Interface1D } else if (BPy_UnaryFunction1DVectorViewShape_Check(obj)) { vector<ViewShape*> vec; + vec.reserve(PyList_Size(result)); for (int i = 1; i < PyList_Size(result); i++) { - ViewShape *b = ((BPy_ViewShape *)PyList_GetItem(result, i))->vs; + ViewShape *b = ((BPy_ViewShape *)PyList_GET_ITEM(result, i))->vs; vec.push_back(b); } ((UnaryFunction1D< vector<ViewShape*> > *)uf1D)->result = vec; |