From 71356b300872d79b99a6ed30a8b20363e70c340d Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Tue, 28 Dec 2021 18:08:53 +0100
Subject: [PATCH] [GL/GEOObjects] addPointVec(): using rvalue for
 pnt_id_name_map.

---
 GeoLib/GEOObjects.cpp | 35 +++++++++++++++++++++++++++--------
 GeoLib/GEOObjects.h   | 11 ++++++++---
 2 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/GeoLib/GEOObjects.cpp b/GeoLib/GEOObjects.cpp
index 68cbe81417a..420caa39ace 100644
--- a/GeoLib/GEOObjects.cpp
+++ b/GeoLib/GEOObjects.cpp
@@ -46,11 +46,31 @@ GEOObjects::~GEOObjects()
     }
 }
 
-void GEOObjects::addPointVec(std::unique_ptr<std::vector<Point*>> points,
-                             std::string& name,
-                             std::unique_ptr<std::map<std::string, std::size_t>>
-                                 pnt_id_name_map,
-                             double eps)
+//void GEOObjects::addPointVec(std::unique_ptr<std::vector<Point*>> points,
+//                             std::string& name,
+//                             std::unique_ptr<std::map<std::string, std::size_t>>
+//                                 pnt_id_name_map,
+//                             double eps)
+//{
+//    isUniquePointVecName(name);
+//    if (!points || points->empty())
+//    {
+//        DBUG(
+//            "GEOObjects::addPointVec(): Failed to create PointVec, because "
+//            "there aren't any points in the given vector.");
+//        return;
+//    }
+//    _pnt_vecs.push_back(new PointVec(name, std::move(points),
+//                                     std::move(pnt_id_name_map),
+//                                     PointVec::PointType::POINT, eps));
+//    _callbacks->addPointVec(name);
+//}
+
+void GEOObjects::addPointVec(
+    std::unique_ptr<std::vector<Point*>> points,
+    std::string& name,
+    std::map<std::string, std::size_t>&& pnt_id_name_map,
+    double const eps)
 {
     isUniquePointVecName(name);
     if (!points || points->empty())
@@ -442,8 +462,7 @@ bool GEOObjects::mergePoints(std::vector<std::string> const& geo_names,
     const std::size_t n_geo_names(geo_names.size());
 
     auto merged_points = std::make_unique<std::vector<GeoLib::Point*>>();
-    auto merged_pnt_names =
-        std::make_unique<std::map<std::string, std::size_t>>();
+    std::map<std::string, std::size_t> merged_pnt_names;
 
     for (std::size_t j(0); j < n_geo_names; ++j)
     {
@@ -473,7 +492,7 @@ bool GEOObjects::mergePoints(std::vector<std::string> const& geo_names,
             std::string const& item_name(pnt_vec->getItemNameByID(k));
             if (!item_name.empty())
             {
-                merged_pnt_names->insert(
+                merged_pnt_names.insert(
                     std::make_pair(item_name, pnt_offsets[j] + k));
             }
         }
diff --git a/GeoLib/GEOObjects.h b/GeoLib/GEOObjects.h
index 25e25c94ec7..a81598a5c5c 100644
--- a/GeoLib/GEOObjects.h
+++ b/GeoLib/GEOObjects.h
@@ -87,12 +87,17 @@ public:
      * @param pnt_id_name_map names corresponding to the points
      * @param eps relative tolerance value for testing of point uniqueness
      */
+    //void addPointVec(
+    //    std::unique_ptr<std::vector<Point*>> points,
+    //    std::string& name,
+    //    std::unique_ptr<std::map<std::string, std::size_t>> pnt_id_name_map =
+    //        nullptr,
+    //    double eps = std::sqrt(std::numeric_limits<double>::epsilon()));
     void addPointVec(
         std::unique_ptr<std::vector<Point*>> points,
         std::string& name,
-        std::unique_ptr<std::map<std::string, std::size_t>> pnt_id_name_map =
-            nullptr,
-        double eps = std::sqrt(std::numeric_limits<double>::epsilon()));
+        std::map<std::string, std::size_t>&& pnt_id_name_map,
+        double const eps = std::sqrt(std::numeric_limits<double>::epsilon()));
 
     /**
      * Returns the point vector with the given name.
-- 
GitLab