@@ -48,17 +48,6 @@ _Py_DECREF_INT(PyLongObject *op)
4848 _Py_DECREF_SPECIALIZED ((PyObject * )op , _PyLong_ExactDealloc );
4949}
5050
51- static inline int
52- /// Return 1 if the object is one of the immortal small ints
53- _long_is_small_int (PyObject * op )
54- {
55- assert (PyLong_Check (op ));
56- PyLongObject * long_object = (PyLongObject * )op ;
57- int is_small_int = (long_object -> long_value .lv_tag & IMMORTALITY_BIT_MASK ) != 0 ;
58- assert ((!is_small_int ) || PyLong_CheckExact (op ));
59- return is_small_int ;
60- }
61-
6251static inline int
6352is_medium_int (stwodigits x )
6453{
@@ -355,6 +344,8 @@ medium_from_stwodigits(stwodigits x)
355344}
356345
357346
347+ /* If a freshly-allocated int is already shared, it must
348+ be a small integer, so negating it must go to PyLong_FromLong */
358349Py_LOCAL_INLINE (void )
359350_PyLong_Negate (PyLongObject * * x_p )
360351{
@@ -366,10 +357,8 @@ _PyLong_Negate(PyLongObject **x_p)
366357 return ;
367358 }
368359
369- /* If a freshly-allocated int is already shared, it must
370- be a small integer, so negating it will fit a single digit */
371- assert (_long_is_small_int ((PyObject * )x ));
372- * x_p = (PyLongObject * )_PyLong_FromSTwoDigits (- medium_value (x ));
360+ * x_p = _PyLong_FromSTwoDigits (- medium_value (x ));
361+ Py_DECREF (x );
373362}
374363
375364#define PYLONG_FROM_INT (UINT_TYPE , INT_TYPE , ival ) \
@@ -3633,6 +3622,16 @@ long_richcompare(PyObject *self, PyObject *other, int op)
36333622 Py_RETURN_RICHCOMPARE (result , 0 , op );
36343623}
36353624
3625+ static inline int
3626+ /// Return 1 if the object is one of the immortal small ints
3627+ _long_is_small_int (PyObject * op )
3628+ {
3629+ PyLongObject * long_object = (PyLongObject * )op ;
3630+ int is_small_int = (long_object -> long_value .lv_tag & IMMORTALITY_BIT_MASK ) != 0 ;
3631+ assert ((!is_small_int ) || PyLong_CheckExact (op ));
3632+ return is_small_int ;
3633+ }
3634+
36363635void
36373636_PyLong_ExactDealloc (PyObject * self )
36383637{
0 commit comments