diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-11-05 04:51:59 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-11-05 04:51:59 +0400 |
commit | 8c5597eb4964086c715b7d0038ddb4c6cb718296 (patch) | |
tree | 34d0a78421e01ee6ceb2b372c85023b55a302d06 /source/blender/freestyle/intern/python/Director.cpp | |
parent | 737239c4c4f1b422c741d53b19bf21939d7382c3 (diff) |
Additional code improvements: avoid unnecessary Python object allocations in Freestyle.
Diffstat (limited to 'source/blender/freestyle/intern/python/Director.cpp')
-rw-r--r-- | source/blender/freestyle/intern/python/Director.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/source/blender/freestyle/intern/python/Director.cpp b/source/blender/freestyle/intern/python/Director.cpp index cd6f9da3e05..011609bb343 100644 --- a/source/blender/freestyle/intern/python/Director.cpp +++ b/source/blender/freestyle/intern/python/Director.cpp @@ -251,14 +251,16 @@ int Director_BPy_UnaryFunction0D___call__(void *uf0D, PyObject *obj, Interface0D ((UnaryFunction0D<unsigned> *)uf0D)->result = PyLong_AsLong(result); } else if (BPy_UnaryFunction0DVec2f_Check(obj)) { - Vec2f *v = Vec2f_ptr_from_Vector(result); - ((UnaryFunction0D<Vec2f> *)uf0D)->result = *v; - delete v; + Vec2f vec; + if (!Vec2f_ptr_from_Vector(result, &vec)) + return -1; + ((UnaryFunction0D<Vec2f> *)uf0D)->result = vec; } else if (BPy_UnaryFunction0DVec3f_Check(obj)) { - Vec3f *v = Vec3f_ptr_from_Vector(result); - ((UnaryFunction0D<Vec3f> *)uf0D)->result = *v; - delete v; + Vec3f vec; + if (!Vec3f_ptr_from_Vector(result, &vec)) + return -1; + ((UnaryFunction0D<Vec3f> *)uf0D)->result = vec; } else if (BPy_UnaryFunction0DVectorViewShape_Check(obj)) { vector<ViewShape*> vec; @@ -301,14 +303,16 @@ int Director_BPy_UnaryFunction1D___call__(void *uf1D, PyObject *obj, Interface1D ((UnaryFunction1D<unsigned> *)uf1D)->result = PyLong_AsLong(result); } else if (BPy_UnaryFunction1DVec2f_Check(obj)) { - Vec2f *v = Vec2f_ptr_from_Vector(result); - ((UnaryFunction1D<Vec2f> *)uf1D)->result = *v; - delete v; + Vec2f vec; + if (!Vec2f_ptr_from_Vector(result, &vec)) + return -1; + ((UnaryFunction1D<Vec2f> *)uf1D)->result = vec; } else if (BPy_UnaryFunction1DVec3f_Check(obj)) { - Vec3f *v = Vec3f_ptr_from_Vector(result); - ((UnaryFunction1D<Vec3f> *)uf1D)->result = *v; - delete v; + Vec3f vec; + if (!Vec3f_ptr_from_Vector(result, &vec)) + return -1; + ((UnaryFunction1D<Vec3f> *)uf1D)->result = vec; } else if (BPy_UnaryFunction1DVectorViewShape_Check(obj)) { vector<ViewShape*> vec; |