lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master f1def2b 1/2: Regularize range-based for state


From: Greg Chicares
Subject: [lmi-commits] [lmi] master f1def2b 1/2: Regularize range-based for statements
Date: Sat, 14 Jan 2017 16:59:26 +0000 (UTC)

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

    Regularize range-based for statements
    
    Always use a reference and write spaces on both sides of the colon.
---
 rate_table.cpp      |   16 ++++++++--------
 rate_table_tool.cpp |    8 ++++----
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/rate_table.cpp b/rate_table.cpp
index c39da08..b36a650 100644
--- a/rate_table.cpp
+++ b/rate_table.cpp
@@ -447,7 +447,7 @@ void writer::write_values
     std::vector<double> little_endian_values;
     little_endian_values.reserve(values.size());
 
-    for(auto v: values)
+    for(auto const& v : values)
         {
         little_endian_values.push_back(swap_bytes_if_big_endian(v));
         }
@@ -686,7 +686,7 @@ void writer::write_values
         os_ << std::fixed << std::setprecision(*num_decimals);
 
         uint16_t age = *min_age;
-        for(auto v: values)
+        for(auto const& v : values)
             {
             os_ << std::setw(text_format::age_width) << age++
                 << std::setw(value_width) << v << "\n";
@@ -800,7 +800,7 @@ boost::optional<field_and_value> parse_field_and_value
         {"Editor"
         ,"WARNING"
         };
-    for(auto const& not_field: known_not_fields)
+    for(auto const& not_field : known_not_fields)
         {
         if(name == not_field)
             {
@@ -1282,7 +1282,7 @@ void table_impl::read_values(std::istream& ifs, uint16_t 
/* length */)
         fatal_error() << "failed to read the values" << std::flush;
         }
 
-    for(auto& v: values_)
+    for(auto& v : values_)
         {
         v = swap_bytes_if_big_endian(v);
         }
@@ -2250,7 +2250,7 @@ unsigned long table_impl::compute_hash_value() const
     oss << std::fixed << std::setprecision(*num_decimals_);
     unsigned const value_width = *num_decimals_ + 2;
 
-    for(auto v: values_)
+    for(auto const& v : values_)
         {
         oss << std::setw(value_width) << v;
         }
@@ -2544,7 +2544,7 @@ void database_impl::remove_index_entry(table::Number 
number)
     index_by_number_.erase(it);
 
     // But also update the remaining lookup map indices.
-    for(auto& e: index_by_number_)
+    for(auto& e : index_by_number_)
         {
         if(index_deleted < e.second)
             {
@@ -2950,7 +2950,7 @@ void database_impl::save(std::ostream& index_os, 
std::ostream& data_os)
 {
     char index_record[e_index_pos_max] = {0};
 
-    for(auto const& i: index_)
+    for(auto const& i : index_)
         {
         shared_ptr<table_impl> const t = do_get_table_impl(i);
 
@@ -3251,7 +3251,7 @@ std::size_t deduce_number_of_decimals(std::string const& 
arg)
 std::size_t deduce_number_of_decimals(std::vector<double> const& values)
 {
     std::size_t z = 0;
-    for(auto v: values)
+    for(auto const& v : values)
         {
         z = std::max(z, deduce_number_of_decimals(value_cast<std::string>(v)));
         }
diff --git a/rate_table_tool.cpp b/rate_table_tool.cpp
index 1eb7dd7..d1c2a1d 100644
--- a/rate_table_tool.cpp
+++ b/rate_table_tool.cpp
@@ -93,7 +93,7 @@ void list_tables(fs::path const& database_filename)
     database const table_file(database_filename);
 
     auto const numbers = get_all_tables_numbers(table_file);
-    for(auto num: numbers)
+    for(auto const& num : numbers)
         {
         table const& t = table_file.find_table(num);
         std::cout
@@ -155,7 +155,7 @@ void merge
                 }
             }
         std::sort(table_names.begin(), table_names.end());
-        for(auto const& j: table_names)
+        for(auto const& j : table_names)
             {
             table const& t = table::read_from_text(j);
             table_file->add_or_replace_table(t);
@@ -233,7 +233,7 @@ void rename_tables
     // This map has all valid table numbers as keys and the value is non-empty
     // iff the table with the corresponding key needs to be renamed to it.
     std::map<table::Number, std::string> name_map;
-    for(auto num: numbers)
+    for(auto const& num : numbers)
         {
         name_map.emplace(num, std::string());
         }
@@ -334,7 +334,7 @@ int verify(fs::path const& database_filename)
     //
     // Make the output ordered by table numbers.
     auto const numbers = get_all_tables_numbers(orig_db);
-    for(auto num: numbers)
+    for(auto const& num : numbers)
         {
         try
             {



reply via email to

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