[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] valyuta/002 1700262 1/8: Make fewer costly assertion
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] valyuta/002 1700262 1/8: Make fewer costly assertions |
Date: |
Mon, 5 Oct 2020 19:57:18 -0400 (EDT) |
branch: valyuta/002
commit 17002627d479414b6dfd5308ff1d36ed8f01164d
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Make fewer costly assertions
See commit 71925816be4 of 20201004T1559Z.
---
round_to.hpp | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/round_to.hpp b/round_to.hpp
index dade585..9ca6597 100644
--- a/round_to.hpp
+++ b/round_to.hpp
@@ -389,11 +389,16 @@ inline currency round_to<RealType>::c(RealType r) const
// ROUNDING move this restriction to rounding_rules
// enabling it here imposes a three-percent overhead
// LMI_ASSERT(decimals() <= 2);
- if(std::numeric_limits<currency::data_type>::is_integer)
+#if defined CURRENCY_HAS_INTEGER_DATATYPE
+// This conditional didn't have zero overhead with 'double';
+// perhaps 'if constexpr' would have worked, but the preprocessor
+// certainly does:
+// if(std::numeric_limits<currency::data_type>::is_integer)
{
// Precondition for casting to integer below:
LMI_ASSERT(decimals() <= currency::cents_digits);
}
+#endif // defined CURRENCY_HAS_INTEGER_DATATYPE
RealType z = static_cast<RealType>
(rounding_function_(static_cast<RealType>(r * scale_fwd_)) *
scale_back_c_
);
@@ -429,7 +434,7 @@ inline std::vector<currency>
round_to<RealType>::c(std::vector<RealType> r) cons
template<typename RealType>
inline currency round_to<RealType>::c(currency z) const
{
- LMI_ASSERT(decimals() <= 2); // ROUNDING similarly restrict rounding_rules
+// LMI_ASSERT(decimals() <= 2); // ROUNDING similarly restrict rounding_rules
// instead, this ought to verify proper rounding
return z;
}
- [lmi-commits] [lmi] valyuta/002 updated (53eefda -> a3f1b6f), Greg Chicares, 2020/10/05
- [lmi-commits] [lmi] valyuta/002 3d21745 3/8: Fix unit tests, Greg Chicares, 2020/10/05
- [lmi-commits] [lmi] valyuta/002 11484a9 7/8: Differentiate integral from floating conversions, Greg Chicares, 2020/10/05
- [lmi-commits] [lmi] valyuta/002 3d1ad5e 2/8: Avoid another run-time check, Greg Chicares, 2020/10/05
- [lmi-commits] [lmi] valyuta/002 1700262 1/8: Make fewer costly assertions,
Greg Chicares <=
- [lmi-commits] [lmi] valyuta/002 a8bfa96 5/8: Improve encapsulation, Greg Chicares, 2020/10/05
- [lmi-commits] [lmi] valyuta/002 a3f1b6f 8/8: Probably prefer floating to integral datatype, Greg Chicares, 2020/10/05
- [lmi-commits] [lmi] valyuta/002 7be2c59 4/8: Comment out member functions that are apparently unused, Greg Chicares, 2020/10/05
- [lmi-commits] [lmi] valyuta/002 bfc32eb 6/8: Use a more appropriate type for 'cents_per_dollar', Greg Chicares, 2020/10/05