Use appendIf(..) method of MessageStringCollector where it is relevant
authorArtem Zhmurov <zhmurov@gmail.com>
Thu, 13 May 2021 08:41:17 +0000 (11:41 +0300)
committerPaul Bauer <paul.bauer.q@gmail.com>
Fri, 14 May 2021 12:21:27 +0000 (12:21 +0000)
Refs #3886

src/gromacs/mdlib/updategroups.cpp
src/gromacs/selection/selectionoption.cpp

index 700276ea3401eaa19e5ad914af28a64166f9a62c..d738a07ec2e7710bb0814c84c3167904ef673a1e 100644 (file)
@@ -786,38 +786,26 @@ UpdateGroups makeUpdateGroups(const gmx::MDLogger&             mdlog,
 
     messages.startContext("When checking whether update groups are usable:");
 
-    if (!useDomainDecomposition)
-    {
-        messages.append(
-                "Domain decomposition is not active, so there is no need for update groups");
-    }
+    messages.appendIf(!useDomainDecomposition,
+                      "Domain decomposition is not active, so there is no need for update groups");
 
-    if (!systemHasConstraintsOrVsites)
-    {
-        messages.append(
-                "No constraints or virtual sites are in use, so it is best not to use update "
-                "groups");
-    }
+    messages.appendIf(!systemHasConstraintsOrVsites,
+                      "No constraints or virtual sites are in use, so it is best not to use update "
+                      "groups");
 
-    if (updateGroupingPerMoleculeType.empty())
-    {
-        messages.append(
-                "At least one moleculetype does not conform to the requirements for using update "
-                "groups");
-    }
+    messages.appendIf(
+            updateGroupingPerMoleculeType.empty(),
+            "At least one moleculetype does not conform to the requirements for using update "
+            "groups");
 
-    if (getenv("GMX_NO_UPDATEGROUPS") != nullptr)
-    {
-        messages.append(
-                "Environment variable GMX_NO_UPDATEGROUPS prohibited the use of update groups");
-    }
+    messages.appendIf(
+            getenv("GMX_NO_UPDATEGROUPS") != nullptr,
+            "Environment variable GMX_NO_UPDATEGROUPS prohibited the use of update groups");
 
     // To use update groups, the large domain-to-domain cutoff
     // distance should be compatible with the box size.
-    if (2 * maxUpdateGroupRadius >= cutoffMargin)
-    {
-        messages.append("The combination of rlist and box size prohibits the use of update groups");
-    }
+    messages.appendIf(2 * maxUpdateGroupRadius >= cutoffMargin,
+                      "The combination of rlist and box size prohibits the use of update groups");
 
     if (!messages.isEmpty())
     {
index fb2717662f33d9b4627345aa17be9d37ad3c4f4a..fb8d6637475d8827d70bbd39867a8b9510e00fe8 100644 (file)
@@ -164,10 +164,8 @@ void SelectionOptionStorage::setAllowedValueCount(int count)
     {
         // Should not throw because efOption_DontCheckMinimumCount is set.
         setMinValueCount(count);
-        if (valueCount() > 0 && valueCount() < count)
-        {
-            errors.append("Too few (valid) values provided");
-        }
+        errors.appendIf((valueCount() > 0 && valueCount() < count),
+                        "Too few (valid) values provided");
     }
     try
     {