From d5eb0bc2d064eac8e58ca05973d3c77b161b77c6 Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Mon, 27 Jan 2020 19:30:34 +0100
Subject: [PATCH] [cleanup] use std::string::empty for better readability

---
 dumux/common/loggingparametertree.hh          | 8 ++++----
 dumux/common/parameters.hh                    | 8 ++++----
 dumux/io/grid/gridmanager_alu.hh              | 2 +-
 dumux/io/grid/gridmanager_foam.hh             | 2 +-
 dumux/io/grid/gridmanager_mmesh.hh            | 2 +-
 dumux/io/grid/gridmanager_oned.hh             | 2 +-
 dumux/io/grid/gridmanager_sp.hh               | 2 +-
 dumux/io/grid/gridmanager_sub.hh              | 4 ++--
 dumux/io/grid/gridmanager_ug.hh               | 2 +-
 dumux/io/grid/gridmanager_yasp.hh             | 2 +-
 dumux/multidomain/staggeredcouplingmanager.hh | 2 +-
 11 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/dumux/common/loggingparametertree.hh b/dumux/common/loggingparametertree.hh
index d6e702e229..8117172a29 100644
--- a/dumux/common/loggingparametertree.hh
+++ b/dumux/common/loggingparametertree.hh
@@ -84,7 +84,7 @@ public:
     bool hasKeyInGroup(const std::string& key,
                        const std::string& groupPrefix) const
     {
-        if (groupPrefix == "")
+        if (groupPrefix.empty())
             return hasKey(key);
 
         if (hasKey(key))
@@ -206,7 +206,7 @@ public:
                              const std::string& key,
                              const std::string& defaultValue) const
     {
-        if (groupPrefix == "")
+        if (groupPrefix.empty())
             return get(key, defaultValue);
 
         // first, look for the compound key
@@ -315,7 +315,7 @@ public:
                    const std::string& key,
                    const T& defaultValue) const
     {
-        if (groupPrefix == "")
+        if (groupPrefix.empty())
             return get<T>(key, defaultValue);
 
         // first, look for the compound key
@@ -386,7 +386,7 @@ public:
     T getFromGroup(const std::string& groupPrefix,
                    const std::string& key) const
     {
-        if (groupPrefix == "")
+        if (groupPrefix.empty())
             return get<T>(key);
 
         // first, look for the compound key
diff --git a/dumux/common/parameters.hh b/dumux/common/parameters.hh
index 2c464fc776..b01b9aa1ad 100644
--- a/dumux/common/parameters.hh
+++ b/dumux/common/parameters.hh
@@ -122,7 +122,7 @@ public:
         parameterFileName = commandLineArgs.get<std::string>("ParameterFile", parameterFileName);
 
         // otherwise use the default name (executable name + .input)
-        if (parameterFileName == "")
+        if (parameterFileName.empty())
         {
             parameterFileName = [&](){
                 std::string defaultName = std::string(argv[0]) + ".input";
@@ -139,7 +139,7 @@ public:
             }();
 
             // if no parameter file was given and also no default names where found, continue without
-            if (parameterFileName == "")
+            if (parameterFileName.empty())
             {
                 if (mpiHelper.size() > 1)
                     std::cout << "Rank " << mpiHelper.rank() << ": ";
@@ -392,7 +392,7 @@ private:
     //! recursively merge all elements
     static void mergeTreeImpl_(Dune::ParameterTree& target, const Dune::ParameterTree& source, bool overwrite, const std::string& group)
     {
-        const auto prefix = group == "" ? "" : group + ".";
+        const auto prefix = group.empty() ? "" : group + ".";
         for (const auto& key : source.getValueKeys())
             if (overwrite || !target.hasKey(key))
                 target[prefix + key] = source[key];
@@ -412,7 +412,7 @@ void setParam(Dune::ParameterTree& params,
               const std::string& key,
               const std::string& value)
 {
-    if(group == "")
+    if(group.empty())
         params[key] = value;
     else
         params[group + "." + key] = value;
diff --git a/dumux/io/grid/gridmanager_alu.hh b/dumux/io/grid/gridmanager_alu.hh
index a2a2387b2d..c84764873e 100644
--- a/dumux/io/grid/gridmanager_alu.hh
+++ b/dumux/io/grid/gridmanager_alu.hh
@@ -119,7 +119,7 @@ public:
         // Didn't find a way to construct the grid
         else
         {
-            const auto prefix = modelParamGroup == "" ? modelParamGroup : modelParamGroup + ".";
+            const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup + ".";
             DUNE_THROW(ParameterException, "Please supply one of the parameters "
                                            << prefix + "Grid.UpperRight"
                                            << ", or a grid file in " << prefix + "Grid.File");
diff --git a/dumux/io/grid/gridmanager_foam.hh b/dumux/io/grid/gridmanager_foam.hh
index e80f1705f0..b591c5be6c 100644
--- a/dumux/io/grid/gridmanager_foam.hh
+++ b/dumux/io/grid/gridmanager_foam.hh
@@ -85,7 +85,7 @@ public:
         // Didn't find a way to construct the grid
         else
         {
-            const auto prefix = modelParamGroup == "" ? modelParamGroup : modelParamGroup + ".";
+            const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup + ".";
             DUNE_THROW(ParameterException, "Please supply one of the parameters "
                                            << prefix + "Grid.UpperRight"
                                            << ", or a grid file in " << prefix + "Grid.File");
diff --git a/dumux/io/grid/gridmanager_mmesh.hh b/dumux/io/grid/gridmanager_mmesh.hh
index 046c91dff0..2ef9d76547 100644
--- a/dumux/io/grid/gridmanager_mmesh.hh
+++ b/dumux/io/grid/gridmanager_mmesh.hh
@@ -109,7 +109,7 @@ public:
         // Didn't find a way to construct the grid
         else
         {
-            const auto prefix = modelParamGroup == "" ? modelParamGroup : modelParamGroup + ".";
+            const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup + ".";
             DUNE_THROW(ParameterException, "Please supply one of the parameters "
                                            << prefix + "Grid.UpperRight"
                                            << ", or a grid file in " << prefix + "Grid.File");
diff --git a/dumux/io/grid/gridmanager_oned.hh b/dumux/io/grid/gridmanager_oned.hh
index 9c65874e42..0ae0026e9b 100644
--- a/dumux/io/grid/gridmanager_oned.hh
+++ b/dumux/io/grid/gridmanager_oned.hh
@@ -93,7 +93,7 @@ public:
         // Didn't find a way to construct the grid
         else
         {
-            const auto prefix = modelParamGroup == "" ? modelParamGroup : modelParamGroup + ".";
+            const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup + ".";
             DUNE_THROW(ParameterException, "Please supply one of the parameters "
                                            << prefix + "Grid.RightBoundary"
                                            << ", or " << prefix + "Grid.Coordinates"
diff --git a/dumux/io/grid/gridmanager_sp.hh b/dumux/io/grid/gridmanager_sp.hh
index becb24da46..95b132053c 100644
--- a/dumux/io/grid/gridmanager_sp.hh
+++ b/dumux/io/grid/gridmanager_sp.hh
@@ -94,7 +94,7 @@ public:
         }
         else
         {
-            const auto prefix = paramGroup == "" ? paramGroup : paramGroup + ".";
+            const auto prefix = paramGroup.empty() ? paramGroup : paramGroup + ".";
             DUNE_THROW(ParameterException, "Please supply a grid file in " << prefix << "Grid.File or " << prefix << "Grid.UpperRight/Cells.");
         }
     }
diff --git a/dumux/io/grid/gridmanager_sub.hh b/dumux/io/grid/gridmanager_sub.hh
index 0b7e8eba0e..88e25f9024 100644
--- a/dumux/io/grid/gridmanager_sub.hh
+++ b/dumux/io/grid/gridmanager_sub.hh
@@ -127,7 +127,7 @@ public:
                       << "Use Dune::VTKWriter to write out your grid manually." << std::endl;
 
             const auto postfix = getParamFromGroup<std::string>(paramGroup, "Problem.Name", "");
-            const std::string name = postfix == "" ? "subgrid" : "subgrid_" + postfix;
+            const std::string name = postfix.empty() ? "subgrid" : "subgrid_" + postfix;
             Dune::DGFWriter<typename Grid::LeafGridView> writer(subgridPtr->leafGridView());
             writer.write(name + ".dgf");
         }
@@ -140,7 +140,7 @@ public:
                       << "Use Dune::VTKWriter to write out your grid manually." << std::endl;
 
             const auto postfix = getParamFromGroup<std::string>(paramGroup, "Problem.Name", "");
-            const std::string name = postfix == "" ? "subgrid" : "subgrid_" + postfix;
+            const std::string name = postfix.empty() ? "subgrid" : "subgrid_" + postfix;
             Dune::VTKWriter<typename Grid::LeafGridView> vtkWriter(subgridPtr->leafGridView());
             vtkWriter.write(name);
         }
diff --git a/dumux/io/grid/gridmanager_ug.hh b/dumux/io/grid/gridmanager_ug.hh
index ceee8055af..6ede5af6bf 100644
--- a/dumux/io/grid/gridmanager_ug.hh
+++ b/dumux/io/grid/gridmanager_ug.hh
@@ -96,7 +96,7 @@ public:
         // Didn't find a way to construct the grid
         else
         {
-            const auto prefix = modelParamGroup == "" ? modelParamGroup : modelParamGroup + ".";
+            const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup + ".";
             DUNE_THROW(ParameterException, "Please supply one of the parameters "
                                            << prefix + "Grid.UpperRight"
                                            << ", or a grid file in " << prefix + "Grid.File");
diff --git a/dumux/io/grid/gridmanager_yasp.hh b/dumux/io/grid/gridmanager_yasp.hh
index 639cf5c80c..2f5d6aae94 100644
--- a/dumux/io/grid/gridmanager_yasp.hh
+++ b/dumux/io/grid/gridmanager_yasp.hh
@@ -100,7 +100,7 @@ public:
         // Didn't find a way to construct the grid
         else
         {
-            const auto prefix = modelParamGroup == "" ? modelParamGroup : modelParamGroup + ".";
+            const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup + ".";
             DUNE_THROW(ParameterException, "Please supply one of the parameters "
                                            << prefix + "Grid.UpperRight"
                                            << ", or a grid file in " << prefix + "Grid.File");
diff --git a/dumux/multidomain/staggeredcouplingmanager.hh b/dumux/multidomain/staggeredcouplingmanager.hh
index fe75d64c4f..9efd3dbc8d 100644
--- a/dumux/multidomain/staggeredcouplingmanager.hh
+++ b/dumux/multidomain/staggeredcouplingmanager.hh
@@ -208,7 +208,7 @@ public:
         constexpr auto prefix = isCellCenter ? "CellCenter" : "Face";
 
         try {
-            if(paramGroup == "")
+            if(paramGroup.empty())
                 return NumericEpsilon<typename Traits::Scalar, numEq>(prefix);
             else
                 return NumericEpsilon<typename Traits::Scalar, numEq>(paramGroup + "." + prefix);
-- 
GitLab