Skip to content

Commit 19cbe69

Browse files
committed
Remove redundant decref in _PyLong_Negate
1 parent 09044dd commit 19cbe69

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Objects/longobject.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,6 @@ medium_from_stwodigits(stwodigits x)
344344
}
345345

346346

347-
/* If a freshly-allocated int is already shared, it must
348-
be a small integer, so negating it must go to PyLong_FromLong */
349347
Py_LOCAL_INLINE(void)
350348
_PyLong_Negate(PyLongObject **x_p)
351349
{
@@ -357,8 +355,10 @@ _PyLong_Negate(PyLongObject **x_p)
357355
return;
358356
}
359357

360-
*x_p = _PyLong_FromSTwoDigits(-medium_value(x));
361-
Py_DECREF(x);
358+
/* If a freshly-allocated int is already shared, it must
359+
be a small integer, so negating it will fit a single digit */
360+
assert(_long_is_small_int((PyObject *)x));
361+
*x_p = (PyLongObject *)_PyLong_FromSTwoDigits(-medium_value(x));
362362
}
363363

364364
#define PYLONG_FROM_INT(UINT_TYPE, INT_TYPE, ival) \

0 commit comments

Comments
 (0)