Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-02-24 11:47:58 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-02-24 11:47:58 +0300
commitcd615f6fcc143cfd630a8d784ea8d59256cfe84e (patch)
treeb85a2d12cc689022f16173ba2bbdcb62a6f2b578 /source/blender/python/intern/bpy_rna_array.c
parent31c7d694e07f610b7a1e6aa44da43a2587511e80 (diff)
found moving verts in pythons 2.5 api is approx 10x slower because the multi-dimensional array assignment reads the array 3 times (typecheck, length-check & for-real).
the length check was running sequence checks on every number which would fail, small speedup by avoiding this. should eventually get this working faster by reading once into an allocated array.
Diffstat (limited to 'source/blender/python/intern/bpy_rna_array.c')
-rw-r--r--source/blender/python/intern/bpy_rna_array.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c
index 72b06c04943..74ce5f66cfd 100644
--- a/source/blender/python/intern/bpy_rna_array.c
+++ b/source/blender/python/intern/bpy_rna_array.c
@@ -110,21 +110,22 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
}
/* Returns the number of items in a single- or multi-dimensional sequence. */
-static int count_items(PyObject *seq)
+static int count_items(PyObject *seq, int dim)
{
int totitem= 0;
- if (PySequence_Check(seq)) {
+ if(dim > 1) {
const int seq_size= PySequence_Size(seq);
int i;
for (i= 0; i < seq_size; i++) {
PyObject *item= PySequence_GetItem(seq, i);
- totitem += count_items(item);
+ totitem += count_items(item, dim - 1);
Py_DECREF(item);
}
}
- else
- totitem= 1;
+ else {
+ totitem= PySequence_Size(seq);
+ }
return totitem;
}
@@ -135,8 +136,8 @@ static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA
int dimsize[MAX_ARRAY_DIMENSION];
int tot, totdim, len;
- tot= count_items(rvalue);
totdim= RNA_property_array_dimension(ptr, prop, dimsize);
+ tot= count_items(rvalue, totdim);
if ((RNA_property_flag(prop) & PROP_DYNAMIC) && lvalue_dim == 0) {
if (RNA_property_array_length(ptr, prop) != tot) {