From 49c815ad006468124978cbfc8810d8014cbc1338 Mon Sep 17 00:00:00 2001
From: Olivier BICHLER <olivier.bichler@cea.fr>
Date: Mon, 4 Sep 2023 11:06:27 +0200
Subject: [PATCH] Make getNodes() return a const ref

---
 include/aidge/graph/GraphView.hpp | 2 +-
 src/graph/Connector.cpp           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/aidge/graph/GraphView.hpp b/include/aidge/graph/GraphView.hpp
index 2e6323d70..f11136ada 100644
--- a/include/aidge/graph/GraphView.hpp
+++ b/include/aidge/graph/GraphView.hpp
@@ -208,7 +208,7 @@ public:
      * @brief Get the Nodes pointed to by the GraphView object.
      * @return std::set<NodePtr>
      */
-    inline std::set<NodePtr> getNodes() const { return mNodes; }
+    inline const std::set<NodePtr>& getNodes() const { return mNodes; }
 
     /**
      * @brief Get the operator with the corresponding name if it is in the
diff --git a/src/graph/Connector.cpp b/src/graph/Connector.cpp
index f189b92b2..cd2ceff8b 100644
--- a/src/graph/Connector.cpp
+++ b/src/graph/Connector.cpp
@@ -39,7 +39,7 @@ std::shared_ptr<Aidge::GraphView> Aidge::generateGraph(std::vector<Connector> ct
             graph->add(nodesToAdd.back());  // only add, connection already done
                                             // between nodes
             std::vector<std::shared_ptr<Node>> parents = nodesToAdd.back()->getParents();
-            std::set<std::shared_ptr<Node>> alreadyAdded = graph->getNodes();
+            const std::set<std::shared_ptr<Node>>& alreadyAdded = graph->getNodes();
             for (std::shared_ptr<Node> parent : parents) {
                 if (alreadyAdded.find(parent) == alreadyAdded.end()) {
                     buffer.push_back(parent);
-- 
GitLab