From 270a58d91ab02c688d27a5f986c258b12cbde760 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sun, 5 Dec 2021 15:55:49 -0700 Subject: [PATCH] Move a check out of an inner loop. --- include/deal.II/base/work_stream.h | 33 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/include/deal.II/base/work_stream.h b/include/deal.II/base/work_stream.h index 1977efda23..882ca45562 100644 --- a/include/deal.II/base/work_stream.h +++ b/include/deal.II/base/work_stream.h @@ -651,26 +651,27 @@ namespace WorkStream tbb::filter::serial, [copier = std::function(copier)]( ItemType *¤t_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; }); -- 2.39.5