Skip to content

Commit a7c4497

Browse files
committed
review comments
1 parent 17f8799 commit a7c4497

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

Objects/enumobject.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,16 @@ enum_traverse(PyObject *op, visitproc visit, void *arg)
178178
static inline PyObject *
179179
increment_longindex_lock_held(enumobject *en)
180180
{
181-
PyObject *next_index = en->en_longindex;
182-
if (next_index == NULL) {
183-
next_index = PyLong_FromSsize_t(PY_SSIZE_T_MAX);
184-
if (next_index == NULL) {
181+
if (en->en_longindex == NULL) {
182+
en->en_longindex = PyLong_FromSsize_t(PY_SSIZE_T_MAX);
183+
if (en->en_longindex == NULL) {
185184
return NULL;
186185
}
187-
en->en_longindex = next_index;
188186
}
189187
assert(next_index != NULL);
188+
// We hold one reference to "next_index" (a.k.a. the old value of
189+
// en->en_longindex); we'll either return it or keep it in en->en_longindex
190+
PyObject *next_index = en->en_longindex;
190191
PyObject *stepped_up = PyNumber_Add(next_index, en->one);
191192
if (stepped_up == NULL) {
192193
return NULL;

0 commit comments

Comments
 (0)