[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [5793] Move assertions to improve speed
From: |
Greg Chicares |
Subject: |
[lmi-commits] [5793] Move assertions to improve speed |
Date: |
Tue, 15 Oct 2013 11:32:29 +0000 |
Revision: 5793
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5793
Author: chicares
Date: 2013-10-15 11:32:26 +0000 (Tue, 15 Oct 2013)
Log Message:
-----------
Move assertions to improve speed
Modified Paths:
--------------
lmi/trunk/gpt_commutation_functions.cpp
lmi/trunk/gpt_commutation_functions.hpp
Modified: lmi/trunk/gpt_commutation_functions.cpp
===================================================================
--- lmi/trunk/gpt_commutation_functions.cpp 2013-10-15 11:13:45 UTC (rev
5792)
+++ lmi/trunk/gpt_commutation_functions.cpp 2013-10-15 11:32:26 UTC (rev
5793)
@@ -140,12 +140,6 @@
/// Calculate GLP or GSP.
///
-/// With both gcc-3.4.5 and como-4.3.10.1, writing any assertion(s)
-/// here makes this function about twenty percent slower. However,
-/// the difference is only about a hundred machine cycles, presumably
-/// due to the overhead of exception handling; that's no reason to
-/// avoid asserting preconditions.
-///
/// Divisions are safe because denominators are asserted upstream to
/// be greater than zero.
@@ -154,8 +148,6 @@
,gpt_scalar_parms const& args
) const
{
- LMI_ASSERT(0 <= args.duration);
- LMI_ASSERT(static_cast<unsigned int>(args.duration) < length_);
double endowment = D_endt_ * args.endt_bft;
double charges =
M_ [args.duration] * args.f3bft
@@ -188,7 +180,8 @@
,std::vector<double> const& gsp_ig
,gpt_vector_parms const& charges
)
- :cf_glp_dbo_1(qc, glp_ic, glp_ig, mce_option1_for_7702, charges)
+ :length_ (qc.size())
+ ,cf_glp_dbo_1(qc, glp_ic, glp_ig, mce_option1_for_7702, charges)
,cf_glp_dbo_2(qc, glp_ic, glp_ig, mce_option2_for_7702, charges)
,cf_gsp (qc, gsp_ic, gsp_ig, mce_option1_for_7702, charges)
{
@@ -220,6 +213,8 @@
,gpt_scalar_parms const& args
) const
{
+ LMI_ASSERT(0 <= args.duration);
+ LMI_ASSERT(static_cast<unsigned int>(args.duration) < length_);
gpt_commfns const*const pcf =
(oe_glp == glp_or_gsp && mce_option1_for_7702 == dbo) ? &cf_glp_dbo_1
: (oe_glp == glp_or_gsp && mce_option2_for_7702 == dbo) ? &cf_glp_dbo_2
Modified: lmi/trunk/gpt_commutation_functions.hpp
===================================================================
--- lmi/trunk/gpt_commutation_functions.hpp 2013-10-15 11:13:45 UTC (rev
5792)
+++ lmi/trunk/gpt_commutation_functions.hpp 2013-10-15 11:32:26 UTC (rev
5793)
@@ -176,6 +176,9 @@
/// distinct for GLP and GSP. Often it is the monthly equivalent of
/// four and six percent, respectively.
///
+/// Data member 'length_' is a dispensable convenience that makes
+/// precondition checks a little clearer.
+///
/// Implicitly-declared special member functions do the right thing.
class gpt_cf_triad
@@ -198,6 +201,7 @@
) const;
private:
+ unsigned int const length_;
gpt_commfns cf_glp_dbo_1;
gpt_commfns cf_glp_dbo_2;
gpt_commfns cf_gsp;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [5793] Move assertions to improve speed,
Greg Chicares <=