Removing dead code.

This commit is contained in:
Daniel Lemire 2021-01-07 18:01:57 -05:00
parent a27fcc230d
commit cad8cfdf57

View File

@ -131,72 +131,6 @@ from_chars_result from_chars(const char *first, const char *last,
return answer;
}
template<typename T>
from_chars_result odlfrom_chars(const char *first, const char *last,
T &value, chars_format fmt /*= chars_format::general*/) noexcept {
static_assert (std::is_same<T, double>::value || std::is_same<T, float>::value, "only float and double are supported");
from_chars_result answer;
while ((first != last) && fast_float::is_space(uint8_t(*first))) {
first++;
}
if (first == last) {
answer.ec = std::errc::invalid_argument;
answer.ptr = first;
return answer;
}
parsed_number_string pns = parse_number_string(first, last, fmt);
if (!pns.valid) {
return parse_infnan(first, last, value);
}
answer.ec = std::errc(); // be optimistic
answer.ptr = pns.lastmatch;
adjusted_mantissa am;
// Most times, we have pns.too_many_digits = false.
if(pns.too_many_digits) {
// Uncommon path where we have too many digits.
//
// credit: R. Oudompheng who first implemented this fast path.
// It does the job of accelerating the slow path since most
// long streams of digits are determined after 19 digits.
// Note that mantissa+1 cannot overflow since mantissa < 10**19 and so
// mantissa+1 <= 10**19 < 2**64.
adjusted_mantissa am1 = compute_float<binary_format<T>>(pns.exponent, pns.mantissa);
adjusted_mantissa am2 = compute_float<binary_format<T>>(pns.exponent, pns.mantissa+1);
// They must both agree and be both a successful result.
if(( am1 == am2 ) && (am1.power2 >= 0)) {
am = am1;
} else {
// long way! (uncommon)
decimal d = parse_decimal(first, last);
am = compute_float<binary_format<T>>(d);
}
to_float(pns.negative, am, value);
} else {
// We are entering the common path where the number of digits is no more than 19.
//
// Next is Clinger's fast path.
if (binary_format<T>::min_exponent_fast_path() <= pns.exponent && pns.exponent <= binary_format<T>::max_exponent_fast_path() && pns.mantissa <=binary_format<T>::max_mantissa_fast_path()) {
value = T(pns.mantissa);
if (pns.exponent < 0) { value = value / binary_format<T>::exact_power_of_ten(-pns.exponent); }
else { value = value * binary_format<T>::exact_power_of_ten(pns.exponent); }
if (pns.negative) { value = -value; }
return answer;
}
// Then we have our main routine.
am = compute_float<binary_format<T>>(pns.exponent, pns.mantissa);
// If we called compute_float<binary_format<T>>(pns.exponent, pns.mantissa) and we have an invalid power (am.power2 < 0),
// then we need to go the long way around again. This is very uncommon.
if(am.power2 < 0) { // long way! (uncommon)
decimal d = parse_decimal(first, last);
am = compute_float<binary_format<T>>(d);
}
to_float(pns.negative, am, value);
}
return answer;
}
} // namespace fast_float
#endif