From 7619fd05501a8cba7569bccf6c894dde6cd7e54e 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 1349f60115..b36f7a4248 100644 --- a/include/deal.II/base/work_stream.h +++ b/include/deal.II/base/work_stream.h @@ -655,26 +655,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