diff options
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r-- | Objects/listobject.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c index d688179..81b40ae 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -216,7 +216,6 @@ int PyList_SetItem(PyObject *op, Py_ssize_t i, PyObject *newitem) { - PyObject *olditem; PyObject **p; if (!PyList_Check(op)) { Py_XDECREF(newitem); @@ -230,9 +229,7 @@ PyList_SetItem(PyObject *op, Py_ssize_t i, return -1; } p = ((PyListObject *)op) -> ob_item + i; - olditem = *p; - *p = newitem; - Py_XDECREF(olditem); + Py_SETREF(*p, newitem); return 0; } @@ -251,7 +248,7 @@ ins1(PyListObject *self, Py_ssize_t where, PyObject *v) return -1; } - if (list_resize(self, n+1) == -1) + if (list_resize(self, n+1) < 0) return -1; if (where < 0) { @@ -291,7 +288,7 @@ app1(PyListObject *self, PyObject *v) return -1; } - if (list_resize(self, n+1) == -1) + if (list_resize(self, n+1) < 0) return -1; Py_INCREF(v); @@ -711,7 +708,7 @@ list_inplace_repeat(PyListObject *self, Py_ssize_t n) return PyErr_NoMemory(); } - if (list_resize(self, size*n) == -1) + if (list_resize(self, size*n) < 0) return NULL; p = size; @@ -730,7 +727,6 @@ list_inplace_repeat(PyListObject *self, Py_ssize_t n) static int list_ass_item(PyListObject *a, Py_ssize_t i, PyObject *v) { - PyObject *old_value; if (i < 0 || i >= Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "list assignment index out of range"); @@ -739,9 +735,7 @@ list_ass_item(PyListObject *a, Py_ssize_t i, PyObject *v) if (v == NULL) return list_ass_slice(a, i, i+1, v); Py_INCREF(v); - old_value = a->ob_item[i]; - a->ob_item[i] = v; - Py_DECREF(old_value); + Py_SETREF(a->ob_item[i], v); return 0; } @@ -804,7 +798,7 @@ listextend(PyListObject *self, PyObject *b) Py_RETURN_NONE; } m = Py_SIZE(self); - if (list_resize(self, m + n) == -1) { + if (list_resize(self, m + n) < 0) { Py_DECREF(b); return NULL; } @@ -832,7 +826,7 @@ listextend(PyListObject *self, PyObject *b) /* Guess a result list size. */ n = PyObject_LengthHint(b, 8); - if (n == -1) { + if (n < 0) { Py_DECREF(it); return NULL; } @@ -840,7 +834,7 @@ listextend(PyListObject *self, PyObject *b) mn = m + n; if (mn >= m) { /* Make room. */ - if (list_resize(self, mn) == -1) + if (list_resize(self, mn) < 0) goto error; /* Make the list sane again. */ Py_SIZE(self) = m; |