mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 16:56:57 +08:00
Introduces fast path for integers.
This commit is contained in:
parent
8ea46c6155
commit
ccecd5048a
@ -91,7 +91,12 @@ from_chars_result from_chars(const char *first, const char *last,
|
||||
}
|
||||
answer.ec = std::errc(); // be optimistic
|
||||
answer.ptr = pns.lastmatch;
|
||||
|
||||
// Special fast path for integers.
|
||||
if((pns.exponent == 0) && !pns.too_many_digits) {
|
||||
value = T(pns.mantissa);
|
||||
if (pns.negative) { value = -value; }
|
||||
return answer;
|
||||
}
|
||||
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); }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user