Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't build useless temporary object (sonar, c++17).
[simgrid.git] / src / smpi / internals / smpi_shared.cpp
index e66a618..aec5e05 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2022. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -126,7 +126,7 @@ static void *smpi_shared_malloc_local(size_t size, const char *file, int line)
 {
   void* mem;
   smpi_source_location loc(file, line);
-  auto res = allocs.insert(std::make_pair(loc, shared_data_t()));
+  auto res  = allocs.try_emplace(loc);
   auto data = res.first;
   if (res.second) {
     // The new element was inserted.
@@ -453,7 +453,7 @@ void smpi_shared_free(void *ptr)
     if (data->count <= 0) {
       close(data->fd);
       allocs.erase(allocs.find(meta->second.data->first));
-      allocs_metadata.erase(ptr);
+      allocs_metadata.erase(meta);
       XBT_DEBUG("Shared free - Local - with removal - of %p", ptr);
     } else {
       XBT_DEBUG("Shared free - Local - no removal - of %p, count = %d", ptr, data->count);
@@ -467,7 +467,7 @@ void smpi_shared_free(void *ptr)
       munmap(ptr, meta->second.size);
       if(meta->second.data->second.count==0){
         delete meta->second.data;
-        allocs_metadata.erase(ptr);
+        allocs_metadata.erase(meta);
       }
     }else{
       xbt_free(ptr);