Issue #26200: The SETREF macro adds unnecessary work in some cases.

This commit is contained in:
Raymond Hettinger 2016-02-08 20:34:49 -08:00
parent 263c448a2e
commit 38418662e0
1 changed files with 4 additions and 1 deletions

View File

@ -1218,6 +1218,7 @@ deque_del_item(dequeobject *deque, Py_ssize_t i)
static int
deque_ass_item(dequeobject *deque, Py_ssize_t i, PyObject *v)
{
PyObject *old_value;
block *b;
Py_ssize_t n, len=Py_SIZE(deque), halflen=(len+1)>>1, index=i;
@ -1246,7 +1247,9 @@ deque_ass_item(dequeobject *deque, Py_ssize_t i, PyObject *v)
b = b->leftlink;
}
Py_INCREF(v);
Py_SETREF(b->data[i], v);
old_value = b->data[i];
b->data[i] = v;
Py_DECREF(old_value);
return 0;
}