From 100ae437bbf750c06299176e21989a202b9153e3 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 19 Jun 2017 00:06:00 -0600 Subject: [PATCH] Return an object by value, rather than filling a reference argument. In times of move assignment operators, there really is no reason any more not to do this. --- source/dofs/dof_handler_policy.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index 453dc077bc..c105f5b648 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -1252,9 +1252,10 @@ namespace internal } - void pack_data (std::vector &buffer) const + std::vector + pack_data () const { - buffer.resize(bytes_for_buffer()); + std::vector buffer (bytes_for_buffer()); char *ptr = &buffer[0]; @@ -1286,6 +1287,8 @@ namespace internal Assert (ptr == &buffer[0]+buffer.size(), ExcInternalError()); + + return buffer; } @@ -1604,7 +1607,7 @@ namespace internal // pack all the data into the buffer for this recipient // and send it. keep data around till we can make sure // that the packet has been received - it->second.pack_data (sendbuffers[idx]); + sendbuffers[idx] = it->second.pack_data (); const int ierr = MPI_Isend(sendbuffers[idx].data(), sendbuffers[idx].size(), MPI_BYTE, it->first, 1100101, tria.get_communicator(), &requests[idx]); @@ -1655,7 +1658,7 @@ namespace internal } // send reply - cell_data_transfer_buffer.pack_data(reply_buffers[idx]); + reply_buffers[idx] = cell_data_transfer_buffer.pack_data(); ierr = MPI_Isend(&(reply_buffers[idx])[0], reply_buffers[idx].size(), MPI_BYTE, status.MPI_SOURCE, 1100102, tria.get_communicator(), &reply_requests[idx]); @@ -1863,11 +1866,10 @@ namespace internal // sending std::vector > sendbuffers (needs_to_get_cells.size()); - std::vector >::iterator buffer = sendbuffers.begin(); std::vector requests (needs_to_get_cells.size()); - unsigned int idx=0; - + unsigned int idx = 0; + std::vector >::iterator buffer = sendbuffers.begin(); for (typename cellmap_t::iterator it=needs_to_get_cells.begin(); it!=needs_to_get_cells.end(); ++it, ++buffer, ++idx) @@ -1881,7 +1883,7 @@ namespace internal // pack all the data into the buffer for this recipient // and send it. keep data around till we can make sure // that the packet has been received - it->second.pack_data (*buffer); + *buffer = it->second.pack_data (); const int ierr = MPI_Isend(&(*buffer)[0], buffer->size(), MPI_BYTE, it->first, 123, tr->get_communicator(), &requests[idx]); -- 2.39.5