Skip to content

Commit d528881

Browse files
committed
make condition a macro
1 parent 9ec033c commit d528881

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Include/internal/pycore_long.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ PyAPI_FUNC(void) _PyLong_ExactDealloc(PyObject *self);
6565
# error "_PY_NSMALLPOSINTS must be greater than or equal to 257"
6666
#endif
6767

68+
#define _IS_LOAD_SMALL_INT(val) ((val) >= 0 && (val) < 256 && (val) < _PY_NSMALLPOSINTS)
69+
6870
// Return a reference to the immortal zero singleton.
6971
// The function cannot return NULL.
7072
static inline PyObject* _PyLong_GetZero(void)

Python/codegen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ codegen_addop_load_const(compiler *c, location loc, PyObject *o)
284284
if (PyLong_CheckExact(o)) {
285285
int overflow;
286286
long val = PyLong_AsLongAndOverflow(o, &overflow);
287-
if (!overflow && val >= 0 && val < 256 && val < _PY_NSMALLPOSINTS) {
287+
if (!overflow && _IS_LOAD_SMALL_INT(val)) {
288288
ADDOP_I(c, loc, LOAD_SMALL_INT, val);
289289
return SUCCESS;
290290
}

0 commit comments

Comments
 (0)