From 192b271c128eac0e48186e6dbb7901d42423b30f Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 7 Jan 2021 18:03:33 -0500 Subject: [PATCH] Removing dead code --- include/fast_float/float_common.h | 38 ------------------- .../fast_float/simple_decimal_conversion.h | 13 ------- 2 files changed, 51 deletions(-) diff --git a/include/fast_float/float_common.h b/include/fast_float/float_common.h index b4a7741..cb15ac2 100644 --- a/include/fast_float/float_common.h +++ b/include/fast_float/float_common.h @@ -203,44 +203,6 @@ struct decimal { // Moves are allowed: decimal(decimal &&) = default; decimal &operator=(decimal &&other) = default; - // Generates a mantissa by truncating to 19 digits. - // This function should be reasonably fast. - // Note that the user is responsible to ensure that digits are - // initialized to zero when there are fewer than 19. - inline uint64_t to_truncated_mantissa() { -#if FASTFLOAT_IS_BIG_ENDIAN == 1 - uint64_t mantissa = 0; - for (uint32_t i = 0; i < max_digit_without_overflow; - i++) { - mantissa = mantissa * 10 + digits[i]; // can be accelerated - } - return mantissa; -#else - uint64_t val; - // 8 first digits - ::memcpy(&val, digits, sizeof(uint64_t)); - val = val * 2561 >> 8; - val = (val & 0x00FF00FF00FF00FF) * 6553601 >> 16; - uint64_t mantissa = - uint32_t((val & 0x0000FFFF0000FFFF) * 42949672960001 >> 32); - // 8 more digits for a total of 16 - ::memcpy(&val, digits + sizeof(uint64_t), sizeof(uint64_t)); - val = val * 2561 >> 8; - val = (val & 0x00FF00FF00FF00FF) * 6553601 >> 16; - uint32_t eight_digits_value = - uint32_t((val & 0x0000FFFF0000FFFF) * 42949672960001 >> 32); - mantissa = 100000000 * mantissa + eight_digits_value; - for (uint32_t i = 2 * sizeof(uint64_t); i < max_digit_without_overflow; - i++) { - mantissa = mantissa * 10 + digits[i]; // can be accelerated - } - return mantissa; -#endif - } - // Generate an exponent matching to_truncated_mantissa() - inline int32_t to_truncated_exponent() { - return decimal_point - int32_t(max_digit_without_overflow); - } }; constexpr static double powers_of_ten_double[] = { diff --git a/include/fast_float/simple_decimal_conversion.h b/include/fast_float/simple_decimal_conversion.h index 1d6fda1..bfb60b6 100644 --- a/include/fast_float/simple_decimal_conversion.h +++ b/include/fast_float/simple_decimal_conversion.h @@ -353,19 +353,6 @@ adjusted_mantissa compute_float(decimal &d) { template adjusted_mantissa parse_long_mantissa(const char *first, const char* last) { decimal d = parse_decimal(first, last); - // In some cases we can get lucky and looking at only the first 19 digits is enough. - // Let us try that. - const uint64_t mantissa = d.to_truncated_mantissa(); - const int64_t exponent = d.to_truncated_exponent(); - // credit: R. Oudompheng who first implemented this fast path (to my knowledge). - // It is rough, but 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(exponent, mantissa); - adjusted_mantissa am2 = compute_float(exponent, mantissa+1); - // They must both agree and be both a successful result. - if(( am1 == am2 ) && (am1.power2 >= 0)) { return am1; } return compute_float(d); }