From: Wolfgang Bangerth Date: Tue, 4 Jan 2022 20:31:59 +0000 (-0700) Subject: Simplify some code. X-Git-Tag: v9.4.0-rc1~655^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d78fe27701b14c2904a0766e59478383846636c9;p=dealii.git Simplify some code. --- diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index d84b3b815b..6a8269c712 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -9348,7 +9348,7 @@ namespace DataOutBase do { getline(in, header); - while ((header.size() != 0) && (header[header.size() - 1] == ' ')) + while ((header.size() != 0) && (header.back() == ' ')) header.erase(header.size() - 1); } while ((header.empty()) && in); diff --git a/source/base/parameter_handler.cc b/source/base/parameter_handler.cc index 83b999dd70..d04dcc340d 100644 --- a/source/base/parameter_handler.cc +++ b/source/base/parameter_handler.cc @@ -2285,13 +2285,13 @@ MultipleParameterLoop::Entry::split_different_values() // pair of braces if (multiple[0] == '{') multiple.erase(0, 1); - if (multiple[multiple.size() - 1] == '}') + if (multiple.back() == '}') multiple.erase(multiple.size() - 1, 1); // erase leading and trailing spaces // in multiple while (std::isspace(multiple[0]) != 0) multiple.erase(0, 1); - while (std::isspace(multiple[multiple.size() - 1]) != 0) + while (std::isspace(multiple.back()) != 0) multiple.erase(multiple.size() - 1, 1); // delete spaces around '|' diff --git a/source/base/utilities.cc b/source/base/utilities.cc index 75fc60b29f..88ca4dcafb 100644 --- a/source/base/utilities.cc +++ b/source/base/utilities.cc @@ -611,7 +611,7 @@ namespace Utilities std::string s = s_; while ((s.size() > 0) && (s[0] == ' ')) s.erase(s.begin()); - while ((s.size() > 0) && (s[s.size() - 1] == ' ')) + while ((s.size() > 0) && (s.back() == ' ')) s.erase(s.end() - 1); // Now convert and see whether we succeed. Note that strtol only @@ -659,7 +659,7 @@ namespace Utilities std::string s = s_; while ((s.size() > 0) && (s[0] == ' ')) s.erase(s.begin()); - while ((s.size() > 0) && (s[s.size() - 1] == ' ')) + while ((s.size() > 0) && (s.back() == ' ')) s.erase(s.end() - 1); // Now convert and see whether we succeed. Note that strtol only @@ -709,7 +709,7 @@ namespace Utilities // as discussed in the documentation, eat whitespace from the end // of the string - while (tmp.size() != 0 && tmp[tmp.size() - 1] == ' ') + while (tmp.size() != 0 && tmp.back() == ' ') tmp.erase(tmp.size() - 1, 1); // split the input list until it is empty. since in every iteration @@ -735,7 +735,7 @@ namespace Utilities // strip spaces from this element's front and end while ((name.size() != 0) && (name[0] == ' ')) name.erase(0, 1); - while (name.size() != 0 && name[name.size() - 1] == ' ') + while (name.size() != 0 && name.back() == ' ') name.erase(name.size() - 1, 1); split_list.push_back(name); @@ -763,7 +763,7 @@ namespace Utilities std::vector lines; // remove trailing spaces - while ((text.size() != 0) && (text[text.size() - 1] == delimiter)) + while ((text.size() != 0) && (text.back() == delimiter)) text.erase(text.size() - 1, 1); // then split the text into lines @@ -778,7 +778,7 @@ namespace Utilities if (pos_newline != std::string::npos && pos_newline <= width) { std::string line(text, 0, pos_newline); - while ((line.size() != 0) && (line[line.size() - 1] == delimiter)) + while ((line.size() != 0) && (line.back() == delimiter)) line.erase(line.size() - 1, 1); lines.push_back(line); text.erase(0, pos_newline + 1); @@ -791,7 +791,7 @@ namespace Utilities if (text.size() < width) { // remove trailing spaces - while ((text.size() != 0) && (text[text.size() - 1] == delimiter)) + while ((text.size() != 0) && (text.back() == delimiter)) text.erase(text.size() - 1, 1); lines.push_back(text); text = ""; @@ -819,7 +819,7 @@ namespace Utilities // location and put it into a single // line, and remove it from 'text' std::string line(text, 0, location); - while ((line.size() != 0) && (line[line.size() - 1] == delimiter)) + while ((line.size() != 0) && (line.back() == delimiter)) line.erase(line.size() - 1, 1); lines.push_back(line); text.erase(0, location); diff --git a/source/fe/fe_q_dg0.cc b/source/fe/fe_q_dg0.cc index 291d83123d..29481744da 100644 --- a/source/fe/fe_q_dg0.cc +++ b/source/fe/fe_q_dg0.cc @@ -199,7 +199,7 @@ FE_Q_DG0::convert_generalized_support_point_values_to_dof_values( } // We don't need the discontinuous function for local interpolation - nodal_dofs[nodal_dofs.size() - 1] = 0.; + nodal_dofs.back() = 0.; } @@ -236,7 +236,7 @@ std::vector FE_Q_DG0::get_riaf_vector(const unsigned int deg) { std::vector riaf(Utilities::fixed_power(deg + 1) + 1, false); - riaf[riaf.size() - 1] = true; + riaf.back() = true; return riaf; }