lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master b710396 8/9: Don't assume--assert


From: Greg Chicares
Subject: [lmi-commits] [lmi] master b710396 8/9: Don't assume--assert
Date: Sat, 17 Feb 2018 11:13:05 -0500 (EST)

branch: master
commit b7103960de875e8ba18a71d71dd2bb17a2978bb9
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Don't assume--assert
    
    Also replaced std::count() with contains() where the latter is meant.
---
 ledger_invariant.cpp | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/ledger_invariant.cpp b/ledger_invariant.cpp
index eb591d6..7127e0e 100644
--- a/ledger_invariant.cpp
+++ b/ledger_invariant.cpp
@@ -26,6 +26,7 @@
 #include "alert.hpp"
 #include "assert_lmi.hpp"
 #include "basic_values.hpp"
+#include "contains.hpp"                 // for CalculateIrrs()
 #include "crc32.hpp"
 #include "database.hpp"
 #include "dbnames.hpp"
@@ -1267,12 +1268,7 @@ LedgerInvariant& LedgerInvariant::PlusEq(LedgerInvariant 
const& a_Addend)
 /// attempt to access such values as irr() arguments would throw).
 /// Here, such impossible calculations are avoided by explicit
 /// logic (they might be avoided implicitly if IRRs were set in
-/// class LedgerVariant instead). In that logic, it is plausibly
-/// assumed that
-///   mce_run_gen_curr_sep_zero
-///   mce_run_gen_guar_sep_zero
-/// are always used in pairs, so that either may be tested as a
-/// proxy for the other.
+/// class LedgerVariant instead).
 ///
 /// TODO ?? This function's purpose is to let formatting routines
 /// decide whether to calculate IRRs, because those calculations
@@ -1289,13 +1285,12 @@ void LedgerInvariant::CalculateIrrs(Ledger const& 
LedgerValues)
 {
     irr_initialized_ = false;
 
-    bool const zero_sepacct_interest_bases_undefined =
-        (0 == std::count
-            (LedgerValues.GetRunBases().begin()
-            ,LedgerValues.GetRunBases().end()
-            ,mce_run_gen_curr_sep_zero
-            )
-        );
+    auto const& r = LedgerValues.GetRunBases();
+    bool const run_curr_sep_zero = contains(r, mce_run_gen_curr_sep_zero);
+    bool const run_guar_sep_zero = contains(r, mce_run_gen_guar_sep_zero);
+    LMI_ASSERT(run_curr_sep_zero == run_guar_sep_zero);
+    // Emphasize that one of those is used as a proxy for both:
+    bool const zero_sepacct_interest_bases_undefined = !run_curr_sep_zero;
     // PDF !! Initialize the '0'-suffixed IRRs regardless.
 
     // Terse aliases for invariants.



reply via email to

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