From: Peter Munch Date: Sat, 6 Jan 2024 12:49:04 +0000 (+0100) Subject: Simplify code internal::extract_remote_rows() X-Git-Tag: relicensing~198^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16417%2Fhead;p=dealii.git Simplify code internal::extract_remote_rows() --- diff --git a/include/deal.II/lac/sparse_matrix_tools.h b/include/deal.II/lac/sparse_matrix_tools.h index c3e0eae385..fac58460cc 100644 --- a/include/deal.II/lac/sparse_matrix_tools.h +++ b/include/deal.II/lac/sparse_matrix_tools.h @@ -252,6 +252,10 @@ namespace SparseMatrixTools std::map data; + std::pair>> + buffer; + for (unsigned int i = 0; i < row_to_procs.size(); ++i) { if (row_to_procs[i].empty()) @@ -262,22 +266,13 @@ namespace SparseMatrixTools const unsigned int row_length = sparsity_pattern.row_length(row); - - std::pair>> - buffer; buffer.first = row; + buffer.second.resize(row_length); - for (unsigned int i = 0; i < row_length; ++i) - { - buffer.second.emplace_back(entry->column(), entry->value()); - - if (i + 1 != row_length) - ++entry; - } + for (unsigned int j = 0; j < row_length; ++j, ++entry) + buffer.second[j] = {entry->column(), entry->value()}; - for (const auto &proc : - row_to_procs[locally_owned_dofs.index_within_set(buffer.first)]) + for (const auto &proc : row_to_procs[i]) data[proc].emplace_back(buffer); }