Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Prefer using emplace() to insert() for smpi keyvals/attributes.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 22 May 2021 11:33:17 +0000 (13:33 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 25 May 2021 08:43:38 +0000 (10:43 +0200)
src/smpi/include/smpi_keyvals.hpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_datatype.cpp

index 6835f52..d1c647d 100644 (file)
@@ -73,7 +73,7 @@ int Keyval::keyval_create(const smpi_copy_fn& copy_fn, const smpi_delete_fn& del
   value->refcount=1;
 
   *keyval = T::keyval_id_;
-  T::keyvals_.insert({*keyval, value});
+  T::keyvals_.emplace(*keyval, value);
   T::keyval_id_++;
   return MPI_SUCCESS;
 }
@@ -135,7 +135,7 @@ template <typename T> int Keyval::attr_put(int keyval, void* attr_value){
     return MPI_ERR_ARG;
   elem->refcount++;
   int flag=0;
-  auto p  = attributes().insert({keyval, attr_value});
+  auto p  = attributes().emplace(keyval, attr_value);
   if (not p.second) {
     int ret = call_deleter<T>((T*)this, elem, keyval,p.first->second,&flag);
     // overwrite previous value
index db2fb04..829cf51 100644 (file)
@@ -98,10 +98,10 @@ int Comm::dup(MPI_Comm* newcomm){
       if (elem->copy_fn.comm_copy_fn == MPI_COMM_DUP_FN ||
           ((elem->copy_fn.comm_copy_fn_fort != MPI_NULL_COPY_FN) && *(int*)*elem->copy_fn.comm_copy_fn_fort == 1)) {
         elem->refcount++;
-        (*newcomm)->attributes().insert({it.first, it.second});
+        (*newcomm)->attributes().emplace(it.first, it.second);
       } else if (flag) {
         elem->refcount++;
-        (*newcomm)->attributes().insert({it.first, value_out});
+        (*newcomm)->attributes().emplace(it.first, value_out);
       }
     }
   }
index 4d940c4..21696e1 100644 (file)
@@ -180,10 +180,10 @@ int Datatype::copy_attrs(Datatype* datatype){
       if (elem->copy_fn.type_copy_fn == MPI_TYPE_DUP_FN ||
           ((elem->copy_fn.type_copy_fn_fort != MPI_NULL_COPY_FN) && (*(int*)*elem->copy_fn.type_copy_fn_fort == 1))) {
         elem->refcount++;
-        attributes().insert({it.first, it.second});
+        attributes().emplace(it.first, it.second);
       } else if (flag) {
         elem->refcount++;
-        attributes().insert({it.first, value_out});
+        attributes().emplace(it.first, value_out);
       }
     }
   }