Skip to content

Commit

Permalink
Remove snprintf FP fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Feb 21, 2022
1 parent ea6f0bf commit 1ba69fb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
1 change: 0 additions & 1 deletion include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -2728,7 +2728,6 @@ struct float_specs {
bool upper : 1;
bool locale : 1;
bool binary32 : 1;
bool fallback : 1;
bool showpoint : 1;
};

Expand Down
10 changes: 3 additions & 7 deletions include/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ template <typename F> struct basic_fp {
}

template <typename Float>
using is_supported = bool_constant<std::numeric_limits<Float>::digits <= 64>;
using is_supported = bool_constant<std::numeric_limits<Float>::is_iec559 &&
std::numeric_limits<Float>::digits <= 64>;

// Assigns d to this and return true iff predecessor is closer than successor.
template <typename Float, FMT_ENABLE_IF(is_supported<Float>::value)>
Expand Down Expand Up @@ -268,10 +269,7 @@ template <typename F> struct basic_fp {
}

template <typename Float, FMT_ENABLE_IF(!is_supported<Float>::value)>
bool assign(Float) {
FMT_ASSERT(false, "");
return false;
}
bool assign(Float) = delete;
};

using fp = basic_fp<unsigned long long>;
Expand Down Expand Up @@ -2207,8 +2205,6 @@ FMT_HEADER_ONLY_CONSTEXPR20 int format_float(Float value, int precision,
return -precision;
}

if (specs.fallback) return snprintf_float(value, precision, specs, buf);

int exp = 0;
bool use_dragon = true;
if (!is_fast_float<Float>()) {
Expand Down
3 changes: 0 additions & 3 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -2260,9 +2260,6 @@ FMT_CONSTEXPR20 auto write(OutputIt out, T value,
precision = 1;
}
if (const_check(std::is_same<T, float>())) fspecs.binary32 = true;
using limits = std::numeric_limits<T>;
if (const_check(!limits::is_iec559 || limits::digits > 64))
fspecs.fallback = true;
int exp = format_float(convert_float(value), precision, fspecs, buffer);
fspecs.precision = precision;
auto fp = big_decimal_fp{buffer.data(), static_cast<int>(buffer.size()), exp};
Expand Down

0 comments on commit 1ba69fb

Please sign in to comment.