]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Replace empty string comparison
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Tue, 9 Apr 2019 12:11:48 +0000 (14:11 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Thu, 11 Apr 2019 13:28:10 +0000 (15:28 +0200)
12 files changed:
include/deal.II/lac/block_matrix_array.h
include/deal.II/lac/swappable_vector.templates.h
source/base/data_out_base.cc
source/base/exceptions.cc
source/base/parameter_acceptor.cc
source/base/parameter_handler.cc
source/base/path_search.cc
source/base/subscriptor.cc
source/base/table_handler.cc
source/base/timer.cc
source/gmsh/utilities.cc
source/grid/grid_in.cc

index 75fd70b812bd2d231b22df392f396c2ef698e7c1..3f8a1022376916efb0e355e01bc1cd9968e402af 100644 (file)
@@ -609,7 +609,7 @@ BlockMatrixArray<number, BlockVectorType>::print_latex(StreamType &out) const
 
       std::ostringstream stream;
 
-      if (array(m->row, m->col) != "" && m->prefix >= 0)
+      if (!array(m->row, m->col).empty() && m->prefix >= 0)
         stream << "+";
       if (m->prefix != 1.)
         stream << m->prefix << 'x';
index 54963f8920f59fc6ca782ee29027c0c93daa0278..74b39b7b722f9176d32ea32d13ecd375d1c2c3ff 100644 (file)
@@ -39,7 +39,7 @@ SwappableVector<number>::SwappableVector(const SwappableVector<number> &v)
   , filename()
   , data_is_preloaded(false)
 {
-  Assert(v.filename == "", ExcInvalidCopyOperation());
+  Assert(v.filename.empty(), ExcInvalidCopyOperation());
 }
 
 
@@ -54,7 +54,7 @@ SwappableVector<number>::~SwappableVector()
   // first, before killing the vector
   // itself
 
-  if (filename != "")
+  if (!filename.empty())
     {
       try
         {
@@ -72,7 +72,7 @@ SwappableVector<number> &
 SwappableVector<number>::operator=(const SwappableVector<number> &v)
 {
   // if necessary, first delete data
-  if (filename != "")
+  if (!filename.empty())
     kill_file();
 
   // if in MT mode, block all other
@@ -97,7 +97,7 @@ SwappableVector<number>::swap_out(const std::string &name)
   // that has not been deleted in the
   // meantime, then we kill that file
   // first
-  if (filename != "")
+  if (!filename.empty())
     kill_file();
 
   filename = name;
@@ -197,7 +197,7 @@ SwappableVector<number>::reload_vector(const bool set_flag)
 {
   (void)set_flag;
 
-  Assert(filename != "", ExcInvalidFilename(filename));
+  Assert(!filename.empty(), ExcInvalidFilename(filename));
   Assert(this->size() == 0, ExcSizeNonzero());
 
   std::ifstream tmp_in(filename.c_str());
@@ -233,7 +233,7 @@ SwappableVector<number>::kill_file()
   // is most probably an error, not?
   Assert(data_is_preloaded == false, ExcInternalError());
 
-  if (filename != "")
+  if (!filename.empty())
     {
       int status = std::remove(filename.c_str());
       (void)status;
index 939c0c905042b9e4f28f9fb55b7c27391210f5e3..719909c3dbd22ed59d5b5d5f2839ec9cf6c4cc4b 100644 (file)
@@ -5345,7 +5345,7 @@ namespace DataOutBase
         // underscores unless a vector name has been specified
         out << "VECTORS ";
 
-        if (std::get<2>(nonscalar_data_range) != "")
+        if (!std::get<2>(nonscalar_data_range).empty())
           out << std::get<2>(nonscalar_data_range);
         else
           {
@@ -5580,7 +5580,7 @@ namespace DataOutBase
             // underscores unless a vector name has been specified
             out << "    <DataArray type=\"Float32\" Name=\"";
 
-            if (std::get<2>(nonscalar_data_range) != "")
+            if (!std::get<2>(nonscalar_data_range).empty())
               out << std::get<2>(nonscalar_data_range);
             else
               {
@@ -5811,7 +5811,7 @@ namespace DataOutBase
         // underscores unless a vector name has been specified
         out << "    <DataArray type=\"Float32\" Name=\"";
 
-        if (name != "")
+        if (!name.empty())
           out << name;
         else
           {
@@ -6025,7 +6025,7 @@ namespace DataOutBase
         // underscores unless a vector name has been specified
         out << "    <PDataArray type=\"Float32\" Name=\"";
 
-        if (std::get<2>(nonscalar_data_range) != "")
+        if (!std::get<2>(nonscalar_data_range).empty())
           out << std::get<2>(nonscalar_data_range);
         else
           {
@@ -7820,7 +7820,7 @@ DataOutBase::write_filtered_data(
 
           // Determine the vector name. Concatenate all the component names with
           // double underscores unless a vector name has been specified
-          if (std::get<2>(nonscalar_data_ranges[n_th_vector]) != "")
+          if (!std::get<2>(nonscalar_data_ranges[n_th_vector]).empty())
             {
               vector_name = std::get<2>(nonscalar_data_ranges[n_th_vector]);
             }
@@ -8565,7 +8565,7 @@ DataOutInterface<dim, spacedim>::validate_dataset_names() const
     for (const auto &range : ranges)
       {
         const std::string &name = std::get<2>(range);
-        if (name != "")
+        if (!name.empty())
           {
             Assert(all_names.find(name) == all_names.end(),
                    ExcMessage(
@@ -9013,7 +9013,7 @@ namespace DataOutBase
           while ((header.size() != 0) && (header[header.size() - 1] == ' '))
             header.erase(header.size() - 1);
         }
-      while ((header == "") && in);
+      while ((header.empty()) && in);
 
       std::ostringstream s;
       s << "[deal.II intermediate Patch<" << dim << ',' << spacedim << ">]";
index 412b3b008cc9ca3b7bdc0a2e30d77832270a416d..9d743306cbaf39217b3e6c869347764e64e74ba5 100644 (file)
@@ -147,7 +147,7 @@ const char *
 ExceptionBase::what() const noexcept
 {
   // If no error c_string was generated so far, do it now:
-  if (what_str == "")
+  if (what_str.empty())
     {
 #ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
       // We have deferred the symbol lookup to this point to avoid costly
index b239541c403feb5e42a35183962fd20686339690..da217ac3ca977ed680684d371b867cea1f5cf9ce 100644 (file)
@@ -47,8 +47,8 @@ ParameterAcceptor::~ParameterAcceptor()
 std::string
 ParameterAcceptor::get_section_name() const
 {
-  return (section_name != "" ? section_name :
-                               boost::core::demangle(typeid(*this).name()));
+  return (!section_name.empty() ? section_name :
+                                  boost::core::demangle(typeid(*this).name()));
 }
 
 
@@ -60,7 +60,7 @@ ParameterAcceptor::initialize(
   ParameterHandler &                  prm)
 {
   declare_all_parameters(prm);
-  if (filename != "")
+  if (!filename.empty())
     {
       // check the extension of input file
       if (filename.substr(filename.find_last_of('.') + 1) == "prm")
@@ -106,7 +106,7 @@ ParameterAcceptor::initialize(
             "Invalid extension of parameter file. Please use .prm or .xml"));
     }
 
-  if (output_filename != "")
+  if (!output_filename.empty())
     {
       std::ofstream outfile(output_filename.c_str());
       Assert(outfile, ExcIO());
index 68e828c745a5a1ebb2323a4016ef5b5dbddc49ad..3e9f4b3e2be1a3df23a02dd202dee42bc7088780 100644 (file)
@@ -494,8 +494,8 @@ namespace
             // make sure we have a corresponding entry in the destination
             // object as well
             const std::string full_path =
-              (current_path == "" ? p->first :
-                                    current_path + path_separator + p->first);
+              (current_path.empty() ? p->first :
+                                      current_path + path_separator + p->first);
 
             const std::string new_value = p->second.get<std::string>("value");
             AssertThrow(destination.get_optional<std::string>(full_path) &&
@@ -533,7 +533,7 @@ namespace
           {
             // it must be a subsection
             read_xml_recursively(p->second,
-                                 (current_path == "" ?
+                                 (current_path.empty() ?
                                     p->first :
                                     current_path + path_separator + p->first),
                                  path_separator,
index 4faee0bd51c81b18a98f863bd275f1c85a44bca6..cf53ddb590308fbc51d5a36d02609556e433c0fd 100644 (file)
@@ -146,7 +146,7 @@ PathSearch::find(const std::string &filename,
 
       // try again with the suffix appended, unless there is
       // no suffix
-      if (suffix != "")
+      if (!suffix.empty())
         {
           real_name = *path + filename + suffix;
           if (debug > 1)
index 3aa98f2d5f7e6a8be27f5babd22155d62d5f8357..973e5d2e1f37fe5abe8d57b5cd7f309ccd5dc975 100644 (file)
@@ -84,7 +84,7 @@ Subscriptor::check_no_subscribers() const noexcept
                               std::string(map_entry.first);
             }
 
-          if (infostring == "")
+          if (infostring.empty())
             infostring = "<none>";
 
           AssertNothrow(counter == 0,
@@ -136,7 +136,7 @@ Subscriptor::subscribe(std::atomic<bool> *const validity,
     object_info = &typeid(*this);
   ++counter;
 
-  const std::string name = (id != "") ? id : unknown_subscriber;
+  const std::string name = (!id.empty()) ? id : unknown_subscriber;
 
   map_iterator it = counter_map.find(name);
   if (it == counter_map.end())
@@ -154,7 +154,7 @@ void
 Subscriptor::unsubscribe(std::atomic<bool> *const validity,
                          const std::string &      id) const
 {
-  const std::string name = (id != "") ? id : unknown_subscriber;
+  const std::string name = (!id.empty()) ? id : unknown_subscriber;
   if (counter == 0)
     {
       AssertNothrow(counter > 0, ExcNoSubscriber(object_info->name(), name));
index 6ae95c51ce2d7d1cbe7e019fc53774e5b53776ac..6342e4f57fc20850f9e0b1e57bd6742bb98607a7 100644 (file)
@@ -722,9 +722,9 @@ TableHandler::write_tex(std::ostream &out, const bool with_header) const
     }
 
   out << "\\end{tabular}" << std::endl << "\\end{center}" << std::endl;
-  if (tex_table_caption != "")
+  if (!tex_table_caption.empty())
     out << "\\caption{" << tex_table_caption << "}" << std::endl;
-  if (tex_table_label != "")
+  if (!tex_table_label.empty())
     out << "\\label{" << tex_table_label << "}" << std::endl;
   out << "\\end{table}" << std::endl;
   if (with_header)
index 13ee1aa8f70dee9c3edf49d4a740e042bbdbb460..119ae4d477bbad905c6ed75f3b63a5291aa21817 100644 (file)
@@ -459,7 +459,7 @@ TimerOutput::leave_subsection(const std::string &section_name)
 
   std::lock_guard<std::mutex> lock(mutex);
 
-  if (section_name != "")
+  if (!section_name.empty())
     {
       Assert(sections.find(section_name) != sections.end(),
              ExcMessage("Cannot delete a section that was never created."));
@@ -472,7 +472,7 @@ TimerOutput::leave_subsection(const std::string &section_name)
   // if no string is given, exit the last
   // active section.
   const std::string actual_section_name =
-    (section_name == "" ? active_sections.back() : section_name);
+    (section_name.empty() ? active_sections.back() : section_name);
 
   sections[actual_section_name].timer.stop();
   sections[actual_section_name].total_wall_time +=
index 456e4fe6f8450499b90ef819b7c46c18ff5cfb04..512196010eefaf6f23f720136a5cec2ccc7a4339 100644 (file)
@@ -59,7 +59,7 @@ namespace Gmsh
   {
     std::string base_name      = prm.output_base_name;
     char        dir_template[] = "ctfbc-XXXXXX";
-    if (base_name == "")
+    if (base_name.empty())
       {
         const char *temp = mkdtemp(dir_template);
         AssertThrow(temp != nullptr,
index 28f2907258f82c17c5b2af3d5156a55304de433c..addc9a384cb5edd8a344b3e189e52edbf6a3caf7 100644 (file)
@@ -382,7 +382,7 @@ GridIn<dim, spacedim>::read_vtk(std::istream &in)
                             set = keyword;
                             break;
                           }
-                      if (set == "")
+                      if (set.empty())
                         // keep ignoring everything until the next SCALARS
                         // keyword
                         continue;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.