@@ -330,21 +330,20 @@ parse_number_string(UC const *p, UC const *pend,
330330 }
331331#endif
332332
333- UC const *const start_digits = p;
333+ auto const *const start_digits = p;
334334
335335 while ((p != pend) && is_integer (*p)) {
336336 // a multiplication by 10 is cheaper than an arbitrary integer
337337 // multiplication
338338 answer.mantissa = static_cast <fast_float::am_mant_t >(
339339 answer.mantissa * 10 +
340- static_cast <fast_float:: am_mant_t >(
340+ static_cast <uint8_t >(
341341 *p - UC (' 0' ))); // might overflow, we will handle the overflow later
342342 ++p;
343343 }
344344
345- UC const *const end_of_integer_part = p;
346- am_digits digit_count =
347- static_cast <am_digits>(end_of_integer_part - start_digits);
345+ auto const *const end_of_integer_part = p;
346+ auto digit_count = static_cast <am_digits>(end_of_integer_part - start_digits);
348347 answer.integer = span<UC const >(start_digits, digit_count);
349348 // We have now parsed the integer part of the mantissa.
350349
@@ -364,17 +363,16 @@ parse_number_string(UC const *p, UC const *pend,
364363 // We can now parse the fraction part of the mantissa.
365364 if ((p != pend) && (*p == options.decimal_point )) {
366365 ++p;
367- UC const *const before = p;
366+ auto const *const before = p;
368367 // can occur at most twice without overflowing, but let it occur more, since
369368 // for integers with many digits, digit parsing is the primary bottleneck.
370369 loop_parse_if_eight_digits (p, pend, answer.mantissa );
371370
372371 while ((p != pend) && is_integer (*p)) {
373- UC const digit = UC (*p - UC (' 0' ));
372+ auto const digit = uint8_t (*p - UC (' 0' ));
374373 answer.mantissa = static_cast <fast_float::am_mant_t >(
375374 answer.mantissa * 10 +
376- static_cast <am_mant_t >(
377- digit)); // in rare cases, this will overflow, but that's ok
375+ digit); // in rare cases, this will overflow, but that's ok
378376 ++p;
379377 }
380378 answer.exponent = static_cast <am_pow_t >(before - p);
@@ -407,7 +405,7 @@ parse_number_string(UC const *p, UC const *pend,
407405 (UC (' D' ) == *p)))
408406#endif
409407 )) {
410- UC const *location_of_e = p;
408+ auto const *location_of_e = p;
411409#ifdef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
412410 ++p;
413411#else
@@ -439,10 +437,10 @@ parse_number_string(UC const *p, UC const *pend,
439437 } else {
440438 // Now let's parse the explicit exponent.
441439 while ((p != pend) && is_integer (*p)) {
442- if (exp_number < 0x10000 ) {
440+ if (exp_number < std::numeric_limits< am_pow_t >:: max () ) {
443441 // check for exponent overflow if we have too many digits.
444- UC const digit = UC (*p - UC (' 0' ));
445- exp_number = 10 * exp_number + static_cast < am_pow_t >( digit) ;
442+ auto const digit = uint8_t (*p - UC (' 0' ));
443+ exp_number = 10 * exp_number + digit;
446444 }
447445 ++p;
448446 }
@@ -474,7 +472,7 @@ parse_number_string(UC const *p, UC const *pend,
474472 // We have to handle the case where we have 0.0000somenumber.
475473 // We need to be mindful of the case where we only have zeroes...
476474 // E.g., 0.000000000...000.
477- UC const *start = start_digits;
475+ auto const *start = start_digits;
478476 while ((start != pend) &&
479477 (*start == UC (' 0' ) || *start == options.decimal_point )) {
480478 if (*start == UC (' 0' )) {
@@ -529,7 +527,7 @@ parse_int_string(UC const *p, UC const *pend, T &value,
529527
530528 from_chars_result_t <UC> answer;
531529
532- UC const *const first = p;
530+ auto const *const first = p;
533531
534532#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
535533 // Read sign
@@ -553,7 +551,7 @@ parse_int_string(UC const *p, UC const *pend, T &value,
553551 }
554552#endif
555553
556- UC const *const start_num = p;
554+ auto const *const start_num = p;
557555
558556 // Skip leading zeros
559557 while (p != pend && *p == UC (' 0' )) {
@@ -562,23 +560,23 @@ parse_int_string(UC const *p, UC const *pend, T &value,
562560
563561 bool const has_leading_zeros = p > start_num;
564562
565- UC const *const start_digits = p;
563+ auto const *const start_digits = p;
566564
567565 // Parse digits
568- uint64_t i = 0 ;
566+ am_mant_t i = 0 ;
569567 if (options.base == 10 ) {
570568 loop_parse_if_eight_digits (p, pend, i); // use SIMD if possible
571569 }
572570 while (p != pend) {
573- uint_fast8_t const digit = ch_to_digit (*p);
571+ auto const digit = ch_to_digit (*p);
574572 if (digit >= options.base ) {
575573 break ;
576574 }
577- i = uint64_t (options.base ) * i + digit; // might overflow, check this later
578- p++ ;
575+ i = am_mant_t (options.base ) * i + digit; // might overflow, check this later
576+ ++p ;
579577 }
580578
581- am_digits const digit_count = static_cast <am_digits>(p - start_digits);
579+ auto const digit_count = static_cast <am_digits>(p - start_digits);
582580
583581 if (digit_count == 0 ) {
584582 if (has_leading_zeros) {
@@ -595,7 +593,7 @@ parse_int_string(UC const *p, UC const *pend, T &value,
595593 answer.ptr = p;
596594
597595 // check u64 overflow
598- uint_fast8_t const max_digits = max_digits_u64 (options.base );
596+ auto const max_digits = max_digits_u64 (options.base );
599597 if (digit_count > max_digits) {
600598 answer.ec = std::errc::result_out_of_range;
601599 return answer;
@@ -608,10 +606,10 @@ parse_int_string(UC const *p, UC const *pend, T &value,
608606 }
609607
610608 // check other types overflow
611- if (!std::is_same<T, uint64_t >::value) {
612- if (i > uint64_t (std::numeric_limits<T>::max ())
609+ if (!std::is_same<T, am_mant_t >::value) {
610+ if (i > am_mant_t (std::numeric_limits<T>::max ())
613611#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
614- + uint64_t (negative)
612+ + uint8_t (negative)
615613#endif
616614 ) {
617615 answer.ec = std::errc::result_out_of_range;
@@ -634,7 +632,7 @@ parse_int_string(UC const *p, UC const *pend, T &value,
634632 // this is always optimized into a neg instruction (note: T is an integer
635633 // type)
636634 value = T (-std::numeric_limits<T>::max () -
637- T (i - uint64_t (std::numeric_limits<T>::max ())));
635+ T (i - am_mant_t (std::numeric_limits<T>::max ())));
638636#ifdef FASTFLOAT_VISUAL_STUDIO
639637#pragma warning(pop)
640638#endif
0 commit comments