Skip to content

Commit cfc91e6

Browse files
committed
macro IS_SMALL_INT -> static-inline is_small_int
1 parent 5ca8bd6 commit cfc91e6

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Objects/longobject.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ static PyLongObject small_ints[NSMALLNEGINTS + NSMALLPOSINTS];
4949
static PyLongObject small_ints[1];
5050
#endif
5151

52-
#define IS_SMALL_INT(ival) (-NSMALLNEGINTS <= (ival) && (ival) < NSMALLPOSINTS)
52+
static inline int
53+
is_small_int(long long ival)
54+
{
55+
return -NSMALLNEGINTS <= ival && ival < NSMALLPOSINTS;
56+
}
5357

5458
#ifdef COUNT_ALLOCS
5559
Py_ssize_t _Py_quick_int_allocs, _Py_quick_neg_int_allocs;
@@ -59,7 +63,7 @@ static PyObject *
5963
get_small_int(sdigit ival)
6064
{
6165
PyObject *v;
62-
assert(IS_SMALL_INT(ival));
66+
assert(is_small_int(ival));
6367
v = (PyObject *)&small_ints[ival + NSMALLNEGINTS];
6468
Py_INCREF(v);
6569
#ifdef COUNT_ALLOCS
@@ -76,7 +80,7 @@ maybe_small_long(PyLongObject *v)
7680
{
7781
if (v && Py_ABS(Py_SIZE(v)) <= 1) {
7882
sdigit ival = MEDIUM_VALUE(v);
79-
if (IS_SMALL_INT(ival)) {
83+
if (is_small_int(ival)) {
8084
Py_DECREF(v);
8185
return (PyLongObject *)get_small_int(ival);
8286
}
@@ -295,7 +299,7 @@ _PyLong_Copy(PyLongObject *src)
295299
i = -(i);
296300
if (i < 2) {
297301
sdigit ival = MEDIUM_VALUE(src);
298-
if (IS_SMALL_INT(ival)) {
302+
if (is_small_int(ival)) {
299303
return get_small_int(ival);
300304
}
301305
}
@@ -319,7 +323,7 @@ PyLong_FromLong(long ival)
319323
int ndigits = 0;
320324
int sign;
321325

322-
if (IS_SMALL_INT(ival)) {
326+
if (is_small_int(ival)) {
323327
return get_small_int((sdigit)ival);
324328
}
325329

@@ -1152,7 +1156,7 @@ PyLong_FromLongLong(long long ival)
11521156
int ndigits = 0;
11531157
int negative = 0;
11541158

1155-
if (IS_SMALL_INT(ival)) {
1159+
if (is_small_int(ival)) {
11561160
return get_small_int((sdigit)ival);
11571161
}
11581162

@@ -1227,7 +1231,7 @@ PyLong_FromSsize_t(Py_ssize_t ival)
12271231
int ndigits = 0;
12281232
int negative = 0;
12291233

1230-
if (IS_SMALL_INT(ival)) {
1234+
if (is_small_int(ival)) {
12311235
return get_small_int((sdigit)ival);
12321236
}
12331237

0 commit comments

Comments
 (0)