From c46cddb558bf62712b96114da88ce55c2a37e8f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20LAIGRE?= Date: Mon, 28 Feb 2022 12:31:29 +0100 Subject: [PATCH] Fix sonar smells MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sébastien LAIGRE --- include/powsybl/math/UndirectedGraph.hpp | 2 +- include/powsybl/math/UndirectedGraph.hxx | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/powsybl/math/UndirectedGraph.hpp b/include/powsybl/math/UndirectedGraph.hpp index 5c9f31ec..bdef1080 100644 --- a/include/powsybl/math/UndirectedGraph.hpp +++ b/include/powsybl/math/UndirectedGraph.hpp @@ -94,7 +94,7 @@ class UndirectedGraph { bool traverse(unsigned long v, const Traverser& traverser) const; - bool traverse(stdcxx::const_range& startingVertices, const Traverser& traverser) const; + bool traverse(const stdcxx::const_range& startingVertices, const Traverser& traverser) const; bool traverse(unsigned long v, const Traverser& traverser, std::vector& encountered) const; diff --git a/include/powsybl/math/UndirectedGraph.hxx b/include/powsybl/math/UndirectedGraph.hxx index 9aac1fe1..2ce09c33 100644 --- a/include/powsybl/math/UndirectedGraph.hxx +++ b/include/powsybl/math/UndirectedGraph.hxx @@ -425,14 +425,12 @@ bool UndirectedGraph::traverse(unsigned long v, const Traverser& traverser } template -bool UndirectedGraph::traverse(stdcxx::const_range& startingVertices, const Traverser& traverser) const { +bool UndirectedGraph::traverse(const stdcxx::const_range& startingVertices, const Traverser& traverser) const { std::vector encountered(m_vertices.size(), false); for (unsigned long startingVertex : startingVertices) { - if (!encountered[startingVertex]) { - if (!traverse(startingVertex, traverser, encountered)) { - return false; - } + if (!encountered[startingVertex] && !traverse(startingVertex, traverser, encountered)) { + return false; } } return true;