From 02b13b82fda35dc99fc16f711b0420bcc9416fa1 Mon Sep 17 00:00:00 2001 From: Juuso Lehtivarjo Date: Tue, 9 Feb 2016 09:21:48 +0200 Subject: [PATCH] Addressed code review suggestions --- Code/GraphMol/Matrices.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Code/GraphMol/Matrices.cpp b/Code/GraphMol/Matrices.cpp index 423ee505b..3653eb567 100644 --- a/Code/GraphMol/Matrices.cpp +++ b/Code/GraphMol/Matrices.cpp @@ -331,8 +331,7 @@ INT_LIST getShortestPath(const ROMol &mol, int aid1, int aid2) { RANGE_CHECK(0, aid2, nats - 1); CHECK_INVARIANT(aid1 != aid2, ""); - INT_VECT pred; - pred.resize(nats, -1); // set all atoms to unprocessed state + INT_VECT pred(nats, -1); // set all atoms to unprocessed state pred[aid1] = -2; // marks begin pred[aid2] = -3; // marks end @@ -345,26 +344,24 @@ INT_LIST getShortestPath(const ROMol &mol, int aid1, int aid2) { int curAid = bfsQ.front(); boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(mol.getAtomWithIdx(curAid)); - while (nbrIdx != endNbrs) { + while (!done && nbrIdx != endNbrs) { switch (pred[*nbrIdx]) { case -1: - pred[*nbrIdx]=curAid; + pred[*nbrIdx] = curAid; bfsQ.push_back(rdcast(*nbrIdx)); break; case -3: // end found pred[*nbrIdx] = curAid; done = true; - goto EXIT_LOOP; break; default: // already processed (or begin) break; } - nbrIdx++; + ++nbrIdx; } bfsQ.pop_front(); } - EXIT_LOOP: INT_LIST res; if (done) { done = false;