]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Remove unnecessary temporary object when copying a vector
authorJean-Paul Pelteret <jppelteret@gmail.com>
Tue, 22 Jan 2019 15:18:57 +0000 (16:18 +0100)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Thu, 24 Jan 2019 07:44:12 +0000 (08:44 +0100)
source/differentiation/ad/ad_drivers.cc

index 3d29e40a5bddbea6bf4fe1ffb50dad69d2538ea4..ff0a9637cf402f9688e9f4fa073e7fac1ad42f5c 100644 (file)
@@ -476,17 +476,13 @@ namespace Differentiation
     {
       // We've chosen to use unsigned shorts for the tape
       // index type (a safety precaution) so we need to
-      // perform a conversion betwwen ADOL-C's native tape
+      // perform a conversion between ADOL-C's native tape
       // index type and that chosen by us.
       std::vector<short> registered_tape_indices_s;
       cachedTraceTags(registered_tape_indices_s);
 
-      std::vector<typename Types<ADNumberType>::tape_index>
-        registered_tape_indices(registered_tape_indices_s.size());
-      std::copy(registered_tape_indices_s.begin(),
-                registered_tape_indices_s.end(),
-                registered_tape_indices.begin());
-      return registered_tape_indices;
+      return std::vector<typename Types<ADNumberType>::tape_index>(
+        registered_tape_indices_s.begin(), registered_tape_indices_s.end());
     }
 
 
@@ -537,8 +533,10 @@ namespace Differentiation
 
       // See ADOL-C manual section 1.7 and comments in last paragraph of
       // section 3.1
-      Assert(status_tape < 4 && status_tape >= -2,
-             ExcIndexRange(status_tape, -2, 4));
+      Assert(
+        status_tape < 4 && status_tape >= -2,
+        ExcMessage(
+          "The tape status is not within the range specified within the ADOL-C documentation."));
       return (status_tape < 0);
     }
 

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.