[Top][All Lists]

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

[lmi-commits] [lmi] master 567fc84 3/4: Reorder statements for robustnes

From: Greg Chicares
Subject: [lmi-commits] [lmi] master 567fc84 3/4: Reorder statements for robustness
Date: Mon, 19 Mar 2018 16:43:03 -0400 (EDT)

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

    Reorder statements for robustness
    scale_unit_ is a simple function of scale_power_, and should therefore
    be set whenever scale_power_ is set. Apparently the original version was
    not actually wrong, because of the particular value to which scale_unit_
    is initialized; but a reader who attempts to trace that logic rigorously
    will endorse this improvement.
 ledger_base.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ledger_base.cpp b/ledger_base.cpp
index 0e88f2b..9ced737 100644
--- a/ledger_base.cpp
+++ b/ledger_base.cpp
@@ -358,14 +358,14 @@ void LedgerBase::ApplyScaleFactor(int decimal_power)
     scale_power_ = decimal_power;
+    scale_unit_ = look_up_scale_unit(scale_power_);
     if(0 == scale_power_)
         // Don't waste time multiplying all these vectors by one
-    scale_unit_ = look_up_scale_unit(scale_power_);
     for(auto& i : ScalableVectors)
         *i.second *= 1.0 / nonstd::power(10.0, scale_power_);

reply via email to

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