[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [61071] trunk/blender/source/blender/ freestyle/intern/python/BPy_Freestyle.cpp: Minor code improvements: avoid unnecessary Python object allocations in Freestyle color blending.

Campbell Barton ideasman42 at gmail.com
Mon Nov 4 01:35:41 CET 2013

Reducing allocations in more places can be done by changing now
Vec2f_ptr_from_PyObject, Vec2f_ptr_from_Vector,
Vec3f_ptr_from_PyObject, Vec3r_ptr_from_PyObject ... etc work.

Just change them to accept the vector as an arg

Vec3r *Vec3r_ptr_from_PyObject(PyObject *obj)
... to ...
bool Vec3r_ptr_from_PyObject(PyObject *obj, Vec3r *vec)
   /* set vec->x,y */
   return success;  /* false == py-exception */

this way the caller can choose to use vectors on the stack (which is
fine in most cases), and only use the heap when its needed.

More information about the Bf-committers mailing list