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/mathutils/mathutils_Matrix.c | |
parent | 96f08bf9a8e0cfcbbc774c3c00c58d405e3dc55c (diff) |
Optimize PySequence_Fast usage
Access arrays directly, avoiding type-check every time.
Diffstat (limited to 'source/blender/python/mathutils/mathutils_Matrix.c')
-rw-r--r-- | source/blender/python/mathutils/mathutils_Matrix.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index e0de5ddbdc0..41baa9b089f 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -2188,7 +2188,7 @@ static PyObject *Matrix_slice(MatrixObject *self, int begin, int end) * sequence slice (set)*/ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *value) { - PyObject *value_fast = NULL; + PyObject *value_fast; if (BaseMath_ReadCallback_ForWrite(self) == -1) return -1; @@ -2203,6 +2203,7 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va return -1; } else { + PyObject **value_fast_items = PySequence_Fast_ITEMS(value_fast); const int size = end - begin; int row, col; float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM]; @@ -2221,7 +2222,7 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va /* parse sub items */ for (row = begin; row < end; row++) { /* parse each sub sequence */ - PyObject *item = PySequence_Fast_GET_ITEM(value_fast, row - begin); + PyObject *item = value_fast_items[row - begin]; if (mathutils_array_parse(vec, self->num_col, self->num_col, item, "matrix[begin:end] = value assignment") == -1) |