]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Silence a PVS studio warning about repeated code. 3394/head
authorDavid Wells <wellsd2@rpi.edu>
Thu, 3 Nov 2016 13:13:32 +0000 (09:13 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Thu, 3 Nov 2016 13:13:32 +0000 (09:13 -0400)
What we had is correct, but this patch should fix the warning (and make
a little less work for the optimizer).

source/base/function_lib.cc

index e4ff6b14a4c9e1edfdbb2b2a41108df8c0c79db7..a2f3b0e244591ae2c7ee91c1d075789441411e56 100644 (file)
@@ -1049,12 +1049,12 @@ namespace Functions
         break;
       case 2:
         result[0] = std::exp(p(0)) * std::exp(p(1));
-        result[1] = std::exp(p(0)) * std::exp(p(1));
+        result[1] = result[0];
         break;
       case 3:
         result[0] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2));
-        result[1] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2));
-        result[2] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2));
+        result[1] = result[0];
+        result[2] = result[0];
         break;
       default:
         Assert(false, ExcNotImplemented());
@@ -1081,12 +1081,12 @@ namespace Functions
             break;
           case 2:
             gradients[i][0] = std::exp(p(0)) * std::exp(p(1));
-            gradients[i][1] = std::exp(p(0)) * std::exp(p(1));
+            gradients[i][1] = gradients[i][0];
             break;
           case 3:
             gradients[i][0] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2));
-            gradients[i][1] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2));
-            gradients[i][2] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2));
+            gradients[i][1] = gradients[i][0];
+            gradients[i][2] = gradients[i][0];
             break;
           default:
             Assert(false, ExcNotImplemented());

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.