[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 1622e2f 7/8: Locally cache certain values
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 1622e2f 7/8: Locally cache certain values |
Date: |
Mon, 31 Jul 2017 17:24:18 -0400 (EDT) |
branch: master
commit 1622e2fee24217d4354c65101115f05460826562
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Locally cache certain values
---
ledger_text_formats.cpp | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/ledger_text_formats.cpp b/ledger_text_formats.cpp
index 0d1126e..5e265ba 100644
--- a/ledger_text_formats.cpp
+++ b/ledger_text_formats.cpp
@@ -1030,6 +1030,9 @@ void FlatTextLedgerPrinter::PrintKeyTerms() const
void FlatTextLedgerPrinter::PrintNumericalSummary() const
{
+ int const age = value_cast<int>(invar().Age);
+ int const max_length = ledger_.GetMaxLength();
+
os_ << center("Numerical summary") << endrow;
os_ << endrow;
os_ << " ------------Guaranteed-------------
-------------Midpoint-------------- ----------Non-guaranteed-----------" <<
endrow;
@@ -1041,14 +1044,14 @@ void FlatTextLedgerPrinter::PrintNumericalSummary()
const
// substitute duration thirty for age seventy: see illustration reg
// section (7)(C)(1).
- std::vector<int> summary_rows = {4, 9, 19, 69 -
value_cast<int>(invar().Age)};
+ std::vector<int> summary_rows = {4, 9, 19, 69 - age};
for(auto const& row : summary_rows)
{
// Skip row if it doesn't exist. For instance, if the issue
// age is 85 and the contract remains in force until age 100,
// then there is no twentieth duration and no age-70 row.
- if(!(0 <= row && row < ledger_.GetMaxLength()))
+ if(!(0 <= row && row < max_length))
{
continue;
}
@@ -1124,7 +1127,8 @@ void FlatTextLedgerPrinter::PrintTabularDetailHeader()
const
void FlatTextLedgerPrinter::PrintTabularDetail() const
{
int const age = value_cast<int>(invar().Age);
- for(int j = 0; j < ledger_.GetMaxLength(); ++j)
+ int const max_length = ledger_.GetMaxLength();
+ for(int j = 0; j < max_length; ++j)
{
os_.setf(std::ios_base::fixed, std::ios_base::floatfield);
os_.precision(0);
- [lmi-commits] [lmi] master updated (e13aa72 -> bd7e567), Greg Chicares, 2017/07/31
- [lmi-commits] [lmi] master 6ceeaf8 1/8: Say why headers are included if not obvious, Greg Chicares, 2017/07/31
- [lmi-commits] [lmi] master 8aea003 2/8: Fix defect introduced 20050114T1947Z: range error, Greg Chicares, 2017/07/31
- [lmi-commits] [lmi] master 5df1ad4 4/8: Resolve several marked defects [384], Greg Chicares, 2017/07/31
- [lmi-commits] [lmi] master 9051064 3/8: Improve label on age-70 row in Numeric Summary [388], Greg Chicares, 2017/07/31
- [lmi-commits] [lmi] master 9edce5a 5/8: Crudely paginate text output, Greg Chicares, 2017/07/31
- [lmi-commits] [lmi] master 615758f 6/8: Improve const-correctness, Greg Chicares, 2017/07/31
- [lmi-commits] [lmi] master bd7e567 8/8: Show lapse years in Numeric Summary, Greg Chicares, 2017/07/31
- [lmi-commits] [lmi] master 1622e2f 7/8: Locally cache certain values,
Greg Chicares <=