Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements in angleiterator.cpp/h files by using cppcheck #1368

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions avogadro/core/angleiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ using namespace std;

AngleIterator::AngleIterator(const Molecule* mol)
: m_current(0, 0, 0), m_mol(mol)
{}
{
}

Angle AngleIterator::begin()
{
Expand Down Expand Up @@ -44,15 +45,14 @@ 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;
}

} // 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)) {
Expand All @@ -67,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;
Expand All @@ -84,4 +84,4 @@ Angle AngleIterator::operator++()
return make_tuple(MaxIndex, MaxIndex, MaxIndex);
} // end ++ operator

} // namespace Avogadro
} // namespace Avogadro::Core
2 changes: 1 addition & 1 deletion avogadro/core/angleiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AVOGADROCORE_EXPORT AngleIterator
/**
* Constructor.
*/
AngleIterator(const Molecule *mol);
explicit AngleIterator(const Molecule *mol);

~AngleIterator() {}

Expand Down