Skip to content

Commit 11ad06f

Browse files
committed
Move back PYLONG_FROM_UINT where it belongs earlier
1 parent 237b8b9 commit 11ad06f

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

Objects/longobject.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -147,34 +147,6 @@ maybe_small_long(PyLongObject *v)
147147
return (PyObject *)v; \
148148
} while(0)
149149

150-
#define PYLONG_FROM_UINT(INT_TYPE, ival) \
151-
do { \
152-
if (IS_SMALL_UINT(ival)) { \
153-
return get_small_int((sdigit)(ival)); \
154-
} \
155-
if ((ival) <= PyLong_MASK) { \
156-
return _PyLong_FromMedium((sdigit)(ival)); \
157-
} \
158-
/* Count the number of Python digits. */ \
159-
Py_ssize_t ndigits = 0; \
160-
INT_TYPE t = (ival); \
161-
while (t) { \
162-
++ndigits; \
163-
t >>= PyLong_SHIFT; \
164-
} \
165-
PyLongObject *v = _PyLong_New(ndigits); \
166-
if (v == NULL) { \
167-
return NULL; \
168-
} \
169-
digit *p = v->long_value.ob_digit; \
170-
t = (ival); \
171-
while (t) { \
172-
*p++ = (digit)(t & PyLong_MASK); \
173-
t >>= PyLong_SHIFT; \
174-
} \
175-
return (PyObject *)v; \
176-
} while(0)
177-
178150
/* Normalize (remove leading zeros from) an int object.
179151
Doesn't attempt to free the storage--in most cases, due to the nature
180152
of the algorithms used, this could save at most be one word anyway. */
@@ -381,6 +353,34 @@ PyLong_FromLong(long ival)
381353
PYLONG_FROM_SIGNED(long, ival);
382354
}
383355

356+
#define PYLONG_FROM_UINT(INT_TYPE, ival) \
357+
do { \
358+
if (IS_SMALL_UINT(ival)) { \
359+
return get_small_int((sdigit)(ival)); \
360+
} \
361+
if ((ival) <= PyLong_MASK) { \
362+
return _PyLong_FromMedium((sdigit)(ival)); \
363+
} \
364+
/* Count the number of Python digits. */ \
365+
Py_ssize_t ndigits = 0; \
366+
INT_TYPE t = (ival); \
367+
while (t) { \
368+
++ndigits; \
369+
t >>= PyLong_SHIFT; \
370+
} \
371+
PyLongObject *v = _PyLong_New(ndigits); \
372+
if (v == NULL) { \
373+
return NULL; \
374+
} \
375+
digit *p = v->long_value.ob_digit; \
376+
t = (ival); \
377+
while (t) { \
378+
*p++ = (digit)(t & PyLong_MASK); \
379+
t >>= PyLong_SHIFT; \
380+
} \
381+
return (PyObject *)v; \
382+
} while(0)
383+
384384
/* Create a new int object from a C unsigned long int */
385385

386386
PyObject *

0 commit comments

Comments
 (0)