lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] valyuta/002 7192581 1/2: Remove three percent of 'cu


From: Greg Chicares
Subject: [lmi-commits] [lmi] valyuta/002 7192581 1/2: Remove three percent of 'currency' overhead
Date: Sun, 4 Oct 2020 12:12:45 -0400 (EDT)

branch: valyuta/002
commit 71925816be4c0a71fa3435513b92f4472787a8d1
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Remove three percent of 'currency' overhead
    
    Generally,
      - a trivial assertion costs almost nothing, and
      - a modern compiler optimizes a class that emulates an arithmetic
        type so well that there's almost no overhead;
    but an assertion in a frequently-called function that's part of that
    class's implementation can impose substantial overhead.
---
 round_to.hpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/round_to.hpp b/round_to.hpp
index 851c2c2..dade585 100644
--- a/round_to.hpp
+++ b/round_to.hpp
@@ -386,7 +386,9 @@ inline std::vector<RealType> 
round_to<RealType>::operator()(std::vector<RealType
 template<typename RealType>
 inline currency round_to<RealType>::c(RealType r) const
 {
-    LMI_ASSERT(decimals() <= 2); // ROUNDING similarly restrict rounding_rules
+    // 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)
         {
         // Precondition for casting to integer below:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]