lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 551c6f5 1/3: Split an 846-line function into


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 551c6f5 1/3: Split an 846-line function into four smaller functions
Date: Sun, 7 Oct 2018 20:04:04 -0400 (EDT)

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

    Split an 846-line function into four smaller functions
    
    Specifying static storage duration for the principal local variable in
    each of the three free functions added in this transitional commit seems
    silly, but will make sense in the next when initializers are supplied.
    Separating this pair of commits facilitates review.
---
 ledger_evaluator.cpp | 52 ++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 38 insertions(+), 14 deletions(-)

diff --git a/ledger_evaluator.cpp b/ledger_evaluator.cpp
index 4213e91..8e508b2 100644
--- a/ledger_evaluator.cpp
+++ b/ledger_evaluator.cpp
@@ -137,18 +137,9 @@ bool format_exists
         }
 }
 
-} // Unnamed namespace.
-
-ledger_evaluator Ledger::make_evaluator() const
+title_map_t static_titles()
 {
-    throw_if_interdicted(*this);
-
-    LedgerInvariant const& invar = GetLedgerInvariant();
-    LedgerVariant   const& curr  = GetCurrFull();
-    LedgerVariant   const& guar  = GetGuarFull();
-
-    title_map_t title_map;
-
+    static title_map_t title_map;
 //  Here are the columns to be listed in the user interface
 //  as well as their corresponding titles.
 
@@ -293,7 +284,12 @@ ledger_evaluator Ledger::make_evaluator() const
     // written in 2006-07. DATABASE !! So consider adding them there
     // when the database is revamped.
 
-    mask_map_t mask_map;
+    return title_map;
+}
+
+mask_map_t static_masks()
+{
+    static mask_map_t mask_map;
 
     mask_map ["AVGenAcct_CurrentZero"           ] = "999,999,999";
     mask_map ["AVGenAcct_GuaranteedZero"        ] = "999,999,999";
@@ -421,6 +417,13 @@ ledger_evaluator Ledger::make_evaluator() const
     mask_map ["TotalLoanBalance_Current"        ] = "999,999,999";
     mask_map ["TotalLoanBalance_Guaranteed"     ] = "999,999,999";
 
+    return mask_map;
+}
+
+format_map_t static_formats()
+{
+    static format_map_t format_map;
+
 // Here's my top-level analysis of the formatting specification.
 //
 // Formats
@@ -444,8 +447,6 @@ ledger_evaluator Ledger::make_evaluator() const
     std::pair<int,oenum_format_style> f3(0, oe_format_percentage);
     std::pair<int,oenum_format_style> f4(2, oe_format_percentage);
 
-    format_map_t format_map;
-
 // > Special Formatting for Scalar Items
 // >
 // F4: scaled by 100, two decimals, with '%' at end:
@@ -672,6 +673,29 @@ ledger_evaluator Ledger::make_evaluator() const
     format_map["TgtPrem"                           ] = f1;
     format_map["TotalLoanBalance"                  ] = f1;
 
+    return format_map;
+}
+} // Unnamed namespace.
+
+ledger_evaluator Ledger::make_evaluator() const
+{
+    throw_if_interdicted(*this);
+
+    LedgerInvariant const& invar = GetLedgerInvariant();
+    LedgerVariant   const& curr  = GetCurrFull();
+    LedgerVariant   const& guar  = GetGuarFull();
+
+    title_map_t title_map {static_titles()};
+
+    mask_map_t mask_map {static_masks()};
+
+    std::pair<int,oenum_format_style> f1(0, oe_format_normal);
+    std::pair<int,oenum_format_style> f2(2, oe_format_normal);
+    std::pair<int,oenum_format_style> f3(0, oe_format_percentage);
+    std::pair<int,oenum_format_style> f4(2, oe_format_percentage);
+
+    format_map_t format_map {static_formats()};
+
     // This is a little tricky. We have some stuff that
     // isn't in the maps inside the ledger classes. We're going to
     // stuff it into a copy of the invariant-ledger class's data.



reply via email to

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