[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.

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Sun Nov 3 15:25:37 CET 2013


Revision: 61071
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=61071
Author:   kjym3
Date:     2013-11-03 14:25:37 +0000 (Sun, 03 Nov 2013)
Log Message:
-----------
Minor code improvements: avoid unnecessary Python object allocations in Freestyle color blending.

Modified Paths:
--------------
    trunk/blender/source/blender/freestyle/intern/python/BPy_Freestyle.cpp

Modified: trunk/blender/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
===================================================================
--- trunk/blender/source/blender/freestyle/intern/python/BPy_Freestyle.cpp	2013-11-03 14:24:02 UTC (rev 61070)
+++ trunk/blender/source/blender/freestyle/intern/python/BPy_Freestyle.cpp	2013-11-03 14:25:37 UTC (rev 61071)
@@ -129,7 +129,6 @@
 	PyObject *obj1, *obj2;
 	char *s;
 	int type;
-	Vec3f *v1 = NULL, *v2 = NULL;
 	float a[3], fac, b[3];
 
 	if (!PyArg_ParseTuple(args, "sOfO", &s, &obj1, &fac, &obj2))
@@ -137,32 +136,20 @@
 	type = ramp_blend_type(s);
 	if (type < 0) {
 		PyErr_SetString(PyExc_TypeError, "argument 1 is an unknown ramp blend type");
-		goto error;
+		return NULL;
 	}
-	v1 = Vec3f_ptr_from_PyObject(obj1);
-	if (!v1) {
+	if (!float_array_from_PyObject(obj1, a, 3)) {
 		PyErr_SetString(PyExc_TypeError,
 		                "argument 2 must be a 3D vector (either a tuple/list of 3 elements or Vector)");
-		goto error;
+		return NULL;
 	}
-	v2 = Vec3f_ptr_from_PyObject(obj2);
-	if (!v2) {
+	if (!float_array_from_PyObject(obj2, b, 3)) {
 		PyErr_SetString(PyExc_TypeError,
 		                "argument 4 must be a 3D vector (either a tuple/list of 3 elements or Vector)");
-		goto error;
+		return NULL;
 	}
-	a[0] = v1->x(); b[0] = v2->x();
-	a[1] = v1->y(); b[1] = v2->y();
-	a[2] = v1->z(); b[2] = v2->z();
 	ramp_blend(type, a, fac, b);
-	delete v1;
-	delete v2;
 	return Vector_CreatePyObject(a, 3, Py_NEW, NULL);
-
-error:
-	if (v1) delete v1;
-	if (v2) delete v2;
-	return NULL;
 }
 
 #include "BKE_texture.h" /* do_colorband() */




More information about the Bf-blender-cvs mailing list