[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 5753253 8/8: Simplify realize_intervals()
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 5753253 8/8: Simplify realize_intervals() |
Date: |
Thu, 23 Feb 2017 05:29:08 -0500 (EST) |
branch: master
commit 57532534af27c765f26919db9652ab491add97ad
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Simplify realize_intervals()
---
input_sequence.cpp | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/input_sequence.cpp b/input_sequence.cpp
index 40fd2b8..a79b842 100644
--- a/input_sequence.cpp
+++ b/input_sequence.cpp
@@ -76,6 +76,8 @@ InputSequence::InputSequence
,allowed_keywords_ (a_allowed_keywords)
,keywords_only_ (a_keywords_only)
,default_keyword_ (a_default_keyword)
+ ,number_result_ (a_years_to_maturity)
+ ,keyword_result_ (a_years_to_maturity, a_default_keyword)
{
// A default keyword should be specified (i.e., nonempty) only for
// keyword-only sequences (otherwise, the default is numeric), and
@@ -313,11 +315,6 @@ std::vector<ValueInterval> const&
InputSequence::interval_representation() const
void InputSequence::realize_intervals()
{
- std::vector<double> r(years_to_maturity_);
- std::vector<std::string> s(years_to_maturity_, default_keyword_);
- number_result_ = r;
- keyword_result_ = s;
-
for(auto const& interval_i : intervals_)
{
LMI_ASSERT(0 <= interval_i.begin_duration);
@@ -326,23 +323,20 @@ void InputSequence::realize_intervals()
if(interval_i.value_is_keyword)
{
std::fill
- (s.begin() + interval_i.begin_duration
- ,s.begin() + interval_i.end_duration
+ (keyword_result_.begin() + interval_i.begin_duration
+ ,keyword_result_.begin() + interval_i.end_duration
,interval_i.value_keyword
);
}
else
{
std::fill
- (r.begin() + interval_i.begin_duration
- ,r.begin() + interval_i.end_duration
+ (number_result_.begin() + interval_i.begin_duration
+ ,number_result_.begin() + interval_i.end_duration
,interval_i.value_number
);
}
}
-
- number_result_ = r;
- keyword_result_ = s;
}
namespace
- [lmi-commits] [lmi] master updated (d7c4f5d -> 5753253), Greg Chicares, 2017/02/23
- [lmi-commits] [lmi] master eff49eb 1/8: Assert more invariants, Greg Chicares, 2017/02/23
- [lmi-commits] [lmi] master 15f8d03 3/8: Assert all post-construction invariants in a single function, Greg Chicares, 2017/02/23
- [lmi-commits] [lmi] master 2f6ea66 6/8: Demonstrate a simplification opportunity, Greg Chicares, 2017/02/23
- [lmi-commits] [lmi] master 3dc9aee 2/8: Refactor to prepare for improvements, Greg Chicares, 2017/02/23
- [lmi-commits] [lmi] master 3a73c40 4/8: Protect known (temporary) weak points with assertions, Greg Chicares, 2017/02/23
- [lmi-commits] [lmi] master 5753253 8/8: Simplify realize_intervals(),
Greg Chicares <=
- [lmi-commits] [lmi] master 132e2ac 7/8: Simplify: only one ctor needs to call realize_intervals(), Greg Chicares, 2017/02/23
- [lmi-commits] [lmi] master 1cfefc0 5/8: Assert post-construction invariants at end of each ctor, Greg Chicares, 2017/02/23