diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-01-04 13:20:45 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-01-04 13:23:26 +0300 |
commit | b240b8e23115fe99f47ee5b3fd66fd3796ff8a1b (patch) | |
tree | 21b3fe18c223d3453ac12ff1de5aa0083e3e8458 /source/blender/freestyle/intern/python/Director.cpp | |
parent | de6b546e15523a0a4ab6da7e5beebaeb15cfa617 (diff) |
Freestyle: reserve array sizes before filling
also use PyList_GET_ITEM when list size is known.
Diffstat (limited to 'source/blender/freestyle/intern/python/Director.cpp')
-rw-r--r-- | source/blender/freestyle/intern/python/Director.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
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; |