Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions 29 Objects/longobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ _Py_DECREF_INT(PyLongObject *op)
_Py_DECREF_SPECIALIZED((PyObject *)op, _PyLong_ExactDealloc);
}

static inline int
/// Return 1 if the object is one of the immortal small ints
_long_is_small_int(PyObject *op)
{
assert(PyLong_Check(op));
PyLongObject *long_object = (PyLongObject *)op;
int is_small_int = (long_object->long_value.lv_tag & IMMORTALITY_BIT_MASK) != 0;
assert((!is_small_int) || PyLong_CheckExact(op));
Comment thread
sergey-miryanov marked this conversation as resolved.
return is_small_int;
}

static inline int
is_medium_int(stwodigits x)
{
Expand Down Expand Up @@ -344,8 +355,6 @@ medium_from_stwodigits(stwodigits x)
}


/* If a freshly-allocated int is already shared, it must
be a small integer, so negating it must go to PyLong_FromLong */
Py_LOCAL_INLINE(void)
_PyLong_Negate(PyLongObject **x_p)
{
Expand All @@ -357,8 +366,10 @@ _PyLong_Negate(PyLongObject **x_p)
return;
}

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

#define PYLONG_FROM_INT(UINT_TYPE, INT_TYPE, ival) \
Expand Down Expand Up @@ -3622,16 +3633,6 @@ long_richcompare(PyObject *self, PyObject *other, int op)
Py_RETURN_RICHCOMPARE(result, 0, op);
}

static inline int
/// Return 1 if the object is one of the immortal small ints
_long_is_small_int(PyObject *op)
{
PyLongObject *long_object = (PyLongObject *)op;
int is_small_int = (long_object->long_value.lv_tag & IMMORTALITY_BIT_MASK) != 0;
assert((!is_small_int) || PyLong_CheckExact(op));
return is_small_int;
}

void
_PyLong_ExactDealloc(PyObject *self)
{
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.