From 8de46e2e34e3e16e1ed82d98cc908a049485ef11 Mon Sep 17 00:00:00 2001 From: Surajjalpun2002 Date: Wed, 11 Oct 2023 03:58:39 +0530 Subject: [PATCH 1/3] Changed a converting constructor to being explicit during its declaration Class 'AngleIterator' has a constructor with 1 argument that is not explicit. Such, so called 'Converting constructors', should in general be explicit for type safety reasons as that prevents unintended implicit conversions. Signed-off-by: Surajjalpun2002 --- avogadro/core/angleiterator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avogadro/core/angleiterator.h b/avogadro/core/angleiterator.h index 3fc7b6dc7..9d2d2bd15 100644 --- a/avogadro/core/angleiterator.h +++ b/avogadro/core/angleiterator.h @@ -26,7 +26,7 @@ class AVOGADROCORE_EXPORT AngleIterator /** * Constructor. */ - AngleIterator(const Molecule *mol); + explicit AngleIterator(const Molecule *mol); ~AngleIterator() {} From 9dee21fb742e04fbf2245360a2beb8e6619698ea Mon Sep 17 00:00:00 2001 From: Surajjalpun2002 Date: Wed, 11 Oct 2023 04:05:30 +0530 Subject: [PATCH 2/3] Removed unnecessary part of the condition The use of valid here is unnecessary and doesn't have any effect because it's always false Condition valid is always false Signed-off-by: Surajjalpun2002 --- avogadro/core/angleiterator.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/avogadro/core/angleiterator.cpp b/avogadro/core/angleiterator.cpp index 4dedc5a43..7ae09f43a 100644 --- a/avogadro/core/angleiterator.cpp +++ b/avogadro/core/angleiterator.cpp @@ -44,8 +44,7 @@ Angle AngleIterator::operator++() if (valid) { // we have a valid current angle, try to find a new edge for (const auto maybeC : graph.neighbors(b)) { - if (maybeC != a - && (!valid || maybeC > c)) { + if (maybeC != a && maybeC > c) { m_current = make_tuple(a, b, maybeC); return m_current; } From 3bc987bfb92c7925cd448f61a5267ff8edca47b3 Mon Sep 17 00:00:00 2001 From: Surajjalpun2002 Date: Wed, 11 Oct 2023 15:33:58 +0530 Subject: [PATCH 3/3] used clang-format to format the document Signed-off-by: Surajjalpun2002 --- avogadro/core/angleiterator.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/avogadro/core/angleiterator.cpp b/avogadro/core/angleiterator.cpp index 7ae09f43a..b555ae0e3 100644 --- a/avogadro/core/angleiterator.cpp +++ b/avogadro/core/angleiterator.cpp @@ -16,7 +16,8 @@ using namespace std; AngleIterator::AngleIterator(const Molecule* mol) : m_current(0, 0, 0), m_mol(mol) -{} +{ +} Angle AngleIterator::begin() { @@ -49,9 +50,9 @@ Angle AngleIterator::operator++() return m_current; } - } // end "c" loop + } // end "c" loop valid = false; // we couldn't find a "c", so find a new "a" - } // end if() + } // end if() // can we find a new edge? for (const auto maybeA : graph.neighbors(b)) { @@ -66,13 +67,13 @@ Angle AngleIterator::operator++() // if we don't have a valid "a", move out to find a new "b" } while (valid); - while(!valid && b + 1 < count) { + while (!valid && b + 1 < count) { ++b; // try going to the next atom const auto neighbors = graph.neighbors(b); if (neighbors.size() < 2) continue; - + a = neighbors[0]; c = neighbors[0]; // we'll move to the next one in the loop valid = true; @@ -83,4 +84,4 @@ Angle AngleIterator::operator++() return make_tuple(MaxIndex, MaxIndex, MaxIndex); } // end ++ operator -} // namespace Avogadro +} // namespace Avogadro::Core