lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [6397] Refactor, temporarily preserving excessive composit


From: Greg Chicares
Subject: [lmi-commits] [6397] Refactor, temporarily preserving excessive composite length
Date: Sat, 07 Nov 2015 21:10:21 +0000

Revision: 6397
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6397
Author:   chicares
Date:     2015-11-07 21:10:20 +0000 (Sat, 07 Nov 2015)
Log Message:
-----------
Refactor, temporarily preserving excessive composite length

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/group_values.cpp
    lmi/trunk/ledger.cpp
    lmi/trunk/ledger_invariant.hpp
    lmi/trunk/ledger_variant.hpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2015-11-07 13:47:45 UTC (rev 6396)
+++ lmi/trunk/ChangeLog 2015-11-07 21:10:20 UTC (rev 6397)
@@ -37456,3 +37456,12 @@
   input_xml_io.cpp
 Improve documentation.
 
+20151107T2110Z <address@hidden> [468]
+
+  group_values.cpp
+  ledger.cpp
+  ledger_invariant.hpp
+  ledger_variant.hpp
+Refactor, temporarily preserving excessive composite length. See:
+  http://lists.nongnu.org/archive/html/lmi/2015-10/msg00005.html
+

Modified: lmi/trunk/group_values.cpp
===================================================================
--- lmi/trunk/group_values.cpp  2015-11-07 13:47:45 UTC (rev 6396)
+++ lmi/trunk/group_values.cpp  2015-11-07 21:10:20 UTC (rev 6397)
@@ -686,22 +686,16 @@
 {
     census_run_result result;
 
-    // Use 100 as the presumptive maximum composite length, assuming
-    // that issue age 0 and endowment age 100 is the worst case. Class
-    // Ledger takes length as a constructor argument, but the true
-    // length is inconvenient to determine here--in particular, when
-    // running life by life, individual cells have not yet been
-    // initialized. The minimum age could be determined by inspecting
-    // all cells' input parameters, but the age at endowment would
-    // require a database lookup for each cell, which would probably
-    // cost more than the overhead of carrying superfluous durations
-    // in the composite ledger. OTOH, doing that (perhaps in class
-    // multiple_cell_document) might not be noticeably slow; and it
-    // may be the best way if coverage beyond age 100 is to be
-    // illustrated someday without any presumptively fixed maximum.
+    // 0 is wanted here; 100 prevents system-testing changes for the nonce.
+    int composite_length = 100;
+    typedef std::vector<Input>::const_iterator svii;
+    for(svii i = cells.begin(); i != cells.end(); ++i)
+        {
+        composite_length = std::max(composite_length, i->years_to_maturity());
+        }
     composite_.reset
         (new Ledger
-            (100
+            (composite_length
             ,cells[0].ledger_type()
             ,false
             ,false
@@ -747,7 +741,7 @@
         }
 
     // Indicate cancellation on the statusbar. This may be of little
-    // importance to end users, yet quite helpful for testing.
+    // importance to end users, but is quite helpful for testing.
     //
     // It might seem like a good idea to write this statusbar message
     // in progress_meter::culminate(), but that function is bypassed

Modified: lmi/trunk/ledger.cpp
===================================================================
--- lmi/trunk/ledger.cpp        2015-11-07 13:47:45 UTC (rev 6396)
+++ lmi/trunk/ledger.cpp        2015-11-07 21:10:20 UTC (rev 6397)
@@ -79,7 +79,7 @@
     ,is_composite_         (is_composite)
     ,composite_lapse_year_ (0.0)
     ,ledger_map_           (new ledger_map_holder)
-    ,ledger_invariant_     (new LedgerInvariant)
+    ,ledger_invariant_     (new LedgerInvariant(length))
 {
     SetRunBases(length);
 }

Modified: lmi/trunk/ledger_invariant.hpp
===================================================================
--- lmi/trunk/ledger_invariant.hpp      2015-11-07 13:47:45 UTC (rev 6396)
+++ lmi/trunk/ledger_invariant.hpp      2015-11-07 21:10:20 UTC (rev 6397)
@@ -46,9 +46,7 @@
     :public LedgerBase
 {
   public:
-    // TODO ?? '100' here is poor. See inline comments on class
-    // Ledger's default ctor.
-    explicit LedgerInvariant(int len = 100);
+    explicit LedgerInvariant(int len);
     LedgerInvariant(LedgerInvariant const&);
     LedgerInvariant& operator=(LedgerInvariant const&);
     virtual ~LedgerInvariant();

Modified: lmi/trunk/ledger_variant.hpp
===================================================================
--- lmi/trunk/ledger_variant.hpp        2015-11-07 13:47:45 UTC (rev 6396)
+++ lmi/trunk/ledger_variant.hpp        2015-11-07 21:10:20 UTC (rev 6397)
@@ -46,11 +46,10 @@
 {
   public:
     // A default ctor is required because this class is used as a
-    // std::map's value_type.
-    //
-    // TODO ?? '100' here is poor. See inline comments on class
-    // Ledger's default ctor.
-    LedgerVariant(int len = 100);
+    // std::map's value_type. It's okay to initialize map contents
+    // with a default argument of zero because they'll be replaced
+    // with new instances created with a nonzero argument.
+    LedgerVariant(int len = 0);
     LedgerVariant(LedgerVariant const&);
     LedgerVariant& operator=(LedgerVariant const&);
     virtual ~LedgerVariant();




reply via email to

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