Skip to content

Commit 73e7b1b

Browse files
committed
review comments
1 parent 750c676 commit 73e7b1b

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

Objects/longobject.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -499,42 +499,46 @@ PyLong_FromDouble(double dval)
499499
#define PY_ABS_SSIZE_T_MIN (0-(size_t)PY_SSIZE_T_MIN)
500500

501501
static inline unsigned long
502-
unroll_digits_ulong(PyLongObject *v, Py_ssize_t *i)
502+
unroll_digits_ulong(PyLongObject *v, Py_ssize_t *iptr)
503503
{
504+
Py_ssize_t i = *iptr;
504505
digit *digits = v->long_value.ob_digit;
505-
assert(*i >= 2);
506+
assert(i >= 2);
506507
/* unroll 1 digit */
507-
--(*i);
508+
--i;
508509
assert(ULONG_MAX >= ((1UL << PyLong_SHIFT) - 1));
509-
unsigned long x = digits[*i];
510+
unsigned long x = digits[i];
510511

511512
#if ((ULONG_MAX >> PyLong_SHIFT)) >= ((1UL << PyLong_SHIFT) - 1)
512513
/* unroll another digit */
513514
x <<= PyLong_SHIFT;
514-
--(*i);
515-
x |= digits[*i];
515+
--i;
516+
x |= digits[i];
516517
#endif
517518

519+
*iptr = i;
518520
return x;
519521
}
520522

521523
static inline size_t
522-
unroll_digits_size_t(PyLongObject *v, Py_ssize_t *i)
524+
unroll_digits_size_t(PyLongObject *v, Py_ssize_t *iptr)
523525
{
526+
Py_ssize_t i = *iptr;
524527
digit *digits = v->long_value.ob_digit;
525-
assert(*i >= 2);
528+
assert(i >= 2);
526529
/* unroll 1 digit */
527-
--(*i);
530+
--i;
528531
assert(SIZE_MAX >= ((1UL << PyLong_SHIFT) - 1));
529-
size_t x = digits[*i];
532+
size_t x = digits[i];
530533

531534
#if ( (SIZE_MAX >> PyLong_SHIFT) >= ( ( 1 << PyLong_SHIFT) - 1) )
532535
/* unroll another digit */
533536
x <<= PyLong_SHIFT;
534-
--(*i);
535-
x |= digits[*i];
537+
--i;
538+
x |= digits[i];
536539
#endif
537540

541+
*iptr = i;
538542
return x;
539543
}
540544

0 commit comments

Comments
 (0)