diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-07-29 02:58:10 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-07-29 03:49:35 +0300 |
commit | 339915a96269ffdd8f48335dda050f4aa071caed (patch) | |
tree | b7723441798a3c0adabd9f1f8a8bd1c154c0f0df /source/blender/python/intern | |
parent | 96f08bf9a8e0cfcbbc774c3c00c58d405e3dc55c (diff) |
Optimize PySequence_Fast usage
Access arrays directly, avoiding type-check every time.
Diffstat (limited to 'source/blender/python/intern')
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 4 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_props.c | 3 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 8 |
3 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 7e5ad00159e..274b33558d3 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -742,9 +742,11 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult * } else { int len = PySequence_Fast_GET_SIZE(seq_fast); + PyObject **seq_fast_items = PySequence_Fast_ITEMS(seq_fast); int i; + for (i = 0; i < len; i++) { - PyObject *list_item = PySequence_Fast_GET_ITEM(seq_fast, i); + PyObject *list_item = seq_fast_items[i]; if (BPy_StructRNA_Check(list_item)) { #if 0 diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 4dcd642634a..6e70f97fd4e 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -1319,6 +1319,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i EnumPropertyItem *items; PyObject *item; const Py_ssize_t seq_len = PySequence_Fast_GET_SIZE(seq_fast); + PyObject **seq_fast_items = PySequence_Fast_ITEMS(seq_fast); Py_ssize_t totbuf = 0; int i; short def_used = 0; @@ -1366,7 +1367,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i Py_ssize_t name_str_size; Py_ssize_t desc_str_size; - item = PySequence_Fast_GET_ITEM(seq_fast, i); + item = seq_fast_items[i]; if ((PyTuple_CheckExact(item)) && (item_size = PyTuple_GET_SIZE(item)) && diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index af4b239d6e1..e74eaefc2b0 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -2637,6 +2637,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop, int start, int stop, int length, PyObject *value_orig) { PyObject *value; + PyObject **value_items; int count; void *values_alloc = NULL; int ret = 0; @@ -2658,6 +2659,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop, return -1; } + value_items = PySequence_Fast_ITEMS(value); switch (RNA_property_type(prop)) { case PROP_FLOAT: { @@ -2673,7 +2675,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop, RNA_property_float_get_array(ptr, prop, values); for (count = start; count < stop; count++) { - fval = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, count - start)); + fval = PyFloat_AsDouble(value_items[count - start]); CLAMP(fval, min, max); values[count] = fval; } @@ -2693,7 +2695,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop, RNA_property_boolean_get_array(ptr, prop, values); for (count = start; count < stop; count++) - values[count] = PyLong_AsLong(PySequence_Fast_GET_ITEM(value, count - start)); + values[count] = PyLong_AsLong(value_items[count - start]); if (PyErr_Occurred()) ret = -1; else RNA_property_boolean_set_array(ptr, prop, values); @@ -2714,7 +2716,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop, RNA_property_int_get_array(ptr, prop, values); for (count = start; count < stop; count++) { - ival = PyLong_AsLong(PySequence_Fast_GET_ITEM(value, count - start)); + ival = PyLong_AsLong(value_items[count - start]); CLAMP(ival, min, max); values[count] = ival; } |