PyAPI: add PyList_APPEND

This appends while giving ownership to the list, avoiding temp assignment.
This matches PyList_SET_ITEM which bypasses refcount's

Note, this also reduce code-size, Py_DECREF is a rather heavy macro.
This commit is contained in:
2015-01-06 17:39:47 +11:00
parent 9fd569a654
commit bf0c8e116d
7 changed files with 30 additions and 64 deletions

View File

@@ -1061,10 +1061,7 @@ static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *a
if (l == len) { /* ok */
/* python */
PyObject *item = Vector_CreatePyObject(potentialVertex, 3, NULL);
PyList_Append(py_verts, item);
Py_DECREF(item);
PyList_APPEND(py_verts, Vector_CreatePyObject(potentialVertex, 3, NULL));
planes_used[i] = planes_used[j] = planes_used[k] = true;
}
}
@@ -1080,9 +1077,7 @@ static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *a
/* now make a list of used planes */
for (i = 0; i < len; i++) {
if (planes_used[i]) {
PyObject *item = PyLong_FromLong(i);
PyList_Append(py_plane_index, item);
Py_DECREF(item);
PyList_APPEND(py_plane_index, PyLong_FromLong(i));
}
}
PyMem_Free(planes_used);