[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master b957c49 1/9: Rewrite write_tsv()
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master b957c49 1/9: Rewrite write_tsv() |
Date: |
Thu, 4 Oct 2018 19:24:14 -0400 (EDT) |
branch: master
commit b957c49c80d06dab595db1b7baf02c2472eb6328
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Rewrite write_tsv()
Reformatted a conditional statement. Reversed its sense, using it only
to conditionalize an early exit. Outdented the former conditional block.
Renamed a local variable. Reformatted a comment block.
---
ledger_evaluator.cpp | 79 ++++++++++++++++++++++++++++------------------------
1 file changed, 42 insertions(+), 37 deletions(-)
diff --git a/ledger_evaluator.cpp b/ledger_evaluator.cpp
index 42f43f9..cb90029 100644
--- a/ledger_evaluator.cpp
+++ b/ledger_evaluator.cpp
@@ -1003,48 +1003,53 @@ void ledger_evaluator::write_tsv
,Ledger const& ledger
) const
{
- if(ledger.is_composite() && contains(global_settings::instance().pyx(),
"values_tsv"))
+ if
+ ( !ledger.is_composite()
+ || !contains(global_settings::instance().pyx(), "values_tsv")
+ )
{
- configurable_settings const& z = configurable_settings::instance();
- fs::path filepath
- ( z.print_directory()
- + "/values"
- + z.spreadsheet_file_extension()
- );
- fs::ofstream ofs(filepath, ios_out_trunc_binary());
-
- // Copy 'vectors_' to a (sorted) std::map in order to
- // show columns alphabetically. Other, more complicated
- // techniques are faster, but direct copying favors simplicity
- // over speed--appropriately, as this facility is rarely used.
- using map_t = std::map<std::string,std::vector<std::string>> const;
- map_t sorted_stringvectors(vectors_.begin(), vectors_.end());
-
- for(auto const& j : sorted_stringvectors)
- {
- ofs << j.first << '\t';
- }
- ofs << '\n';
+ return;
+ }
+
+ configurable_settings const& z = configurable_settings::instance();
+ fs::path filepath
+ ( z.print_directory()
+ + "/values"
+ + z.spreadsheet_file_extension()
+ );
+ fs::ofstream ofs(filepath, ios_out_trunc_binary());
+
+ // Copy 'vectors_' to a (sorted) std::map in order to show columns
+ // alphabetically. Other, more complicated techniques are faster,
+ // but direct copying favors simplicity over speed--appropriately,
+ // as this facility is rarely used.
+ using map_t = std::map<std::string,std::vector<std::string>> const;
+ map_t sorted_vectors(vectors_.begin(), vectors_.end());
+
+ for(auto const& j : sorted_vectors)
+ {
+ ofs << j.first << '\t';
+ }
+ ofs << '\n';
- for(int i = 0; i < ledger.GetMaxLength(); ++i)
+ for(int i = 0; i < ledger.GetMaxLength(); ++i)
+ {
+ for(auto const& j : sorted_vectors)
{
- for(auto const& j : sorted_stringvectors)
+ std::vector<std::string> const& v = j.second;
+ if(i < lmi::ssize(v))
{
- std::vector<std::string> const& v = j.second;
- if(i < lmi::ssize(v))
- {
- ofs << v[i] << '\t';
- }
- else
- {
- ofs << '\t';
- }
+ ofs << v[i] << '\t';
+ }
+ else
+ {
+ ofs << '\t';
}
- ofs << '\n';
- }
- if(!ofs)
- {
- alarum() << "Unable to write '" << filepath << "'." << LMI_FLUSH;
}
+ ofs << '\n';
+ }
+ if(!ofs)
+ {
+ alarum() << "Unable to write '" << filepath << "'." << LMI_FLUSH;
}
}
- [lmi-commits] [lmi] master updated (b3e084f -> b36660c), Greg Chicares, 2018/10/04
- [lmi-commits] [lmi] master af5a41d 2/9: Demonstrate the nugatoriness of composite_lapse_year_, Greg Chicares, 2018/10/04
- [lmi-commits] [lmi] master b957c49 1/9: Rewrite write_tsv(),
Greg Chicares <=
- [lmi-commits] [lmi] master 1d9b6e9 4/9: Store a useful value; discard a useless one, Greg Chicares, 2018/10/04
- [lmi-commits] [lmi] master 579a4f4 3/9: Simplify [378], Greg Chicares, 2018/10/04
- [lmi-commits] [lmi] master fac6d21 8/9: Rename local variables in one function, Greg Chicares, 2018/10/04
- [lmi-commits] [lmi] master 4c6e6c3 6/9: Prefer bourn_cast to static_cast for arithmetic type conversions, Greg Chicares, 2018/10/04
- [lmi-commits] [lmi] master b36660c 9/9: Define short aliases early; use them wherever possible, Greg Chicares, 2018/10/04
- [lmi-commits] [lmi] master 18f1ca3 7/9: Refactor to remove duplication, Greg Chicares, 2018/10/04
- [lmi-commits] [lmi] master 797a8b8 5/9: Rename a member function, Greg Chicares, 2018/10/04