]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move a check out of an inner loop.
authorWolfgang Bangerth <bangerth@colostate.edu>
Sun, 5 Dec 2021 22:55:49 +0000 (15:55 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Mon, 6 Dec 2021 03:34:03 +0000 (20:34 -0700)
include/deal.II/base/work_stream.h

index 1977efda23f1d18e9384145205169498bddd2e41..882ca45562788e230198f0fd5948167dc67df036 100644 (file)
@@ -651,26 +651,27 @@ namespace WorkStream
           tbb::filter::serial,
           [copier = std::function<void(const CopyData &)>(copier)](
             ItemType *&current_item) {
-            // Initiate copying data. For the same reasons as in the worker
-            // class above, catch exceptions rather than letting them propagate
-            // into unknown territories:
-            for (unsigned int i = 0; i < current_item->n_items; ++i)
+            if (copier)
               {
-                try
+                // Initiate copying data. For the same reasons as in the worker
+                // class above, catch exceptions rather than letting them
+                // propagate into unknown territories:
+                for (unsigned int i = 0; i < current_item->n_items; ++i)
                   {
-                    if (copier)
-                      copier(current_item->copy_datas[i]);
-                  }
-                catch (const std::exception &exc)
-                  {
-                    Threads::internal::handle_std_exception(exc);
-                  }
-                catch (...)
-                  {
-                    Threads::internal::handle_unknown_exception();
+                    try
+                      {
+                        copier(current_item->copy_datas[i]);
+                      }
+                    catch (const std::exception &exc)
+                      {
+                        Threads::internal::handle_std_exception(exc);
+                      }
+                    catch (...)
+                      {
+                        Threads::internal::handle_unknown_exception();
+                      }
                   }
               }
-
             // mark current item as usable again
             current_item->currently_in_use = false;
           });

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.