# HG changeset patch # User Chris Cannam # Date 1425553172 0 # Node ID 0df914e353e117e8dea1b6ac3c8b8a8e241e52e1 # Parent 97cc0b9135e7273039d9829475ef21c7e53dbc45 Fix some erroneous uses of -1 where INVALID_PATHCOST was intended diff -r 97cc0b9135e7 -r 0df914e353e1 src/Finder.cpp --- a/src/Finder.cpp Thu Mar 05 09:47:15 2015 +0000 +++ b/src/Finder.cpp Thu Mar 05 10:59:32 2015 +0000 @@ -149,7 +149,7 @@ int bestRow = row; int bestCol = col; - normpathcost_t bestCost = -1; + normpathcost_t bestCost = INVALID_PATHCOST; // cerr << "Finder " << this << "::getExpandDirection: "; @@ -190,7 +190,7 @@ m_m->getDiagonalWeight()); if (r > r1) { // not first row - pathcost_t min = -1; + pathcost_t min = INVALID_PATHCOST; if ((c > prevRowStart) && (c <= prevRowStop)) { // diagonal from (r-1,c-1) min = m_m->getPathCost(r-1, c-1) + diagIncrement; @@ -199,7 +199,7 @@ if ((c >= prevRowStart) && (c < prevRowStop)) { // vertical from (r-1,c) pathcost_t cost = m_m->getPathCost(r-1, c) + straightIncrement; - if ((min < 0) || (cost < min)) { + if ((min == INVALID_PATHCOST) || (cost < min)) { min = cost; dir = AdvanceThis; } @@ -207,7 +207,7 @@ if (c > rowStart) { // horizontal from (r,c-1) pathcost_t cost = m_m->getPathCost(r, c-1) + straightIncrement; - if ((min < 0) || (cost < min)) { + if ((min == INVALID_PATHCOST) || (cost < min)) { min = cost; dir = AdvanceOther; } @@ -261,7 +261,7 @@ err.distance = distance; if (r > r1) { // not first row - pathcost_t min = -1; + pathcost_t min = INVALID_PATHCOST; if ((c > prevRowStart) && (c <= prevRowStop)) { // diagonal from (r-1,c-1) min = m_m->getPathCost(r-1, c-1) + diagIncrement; @@ -271,7 +271,7 @@ if ((c >= prevRowStart) && (c < prevRowStop)) { // vertical from (r-1,c) pathcost_t cost = m_m->getPathCost(r-1, c) + straightIncrement; - if ((min < 0) || (cost < min)) { + if ((min == INVALID_PATHCOST) || (cost < min)) { min = cost; err.prevCost = m_m->getPathCost(r-1, c); dir = AdvanceThis; @@ -280,7 +280,7 @@ if (c > rowStart) { // horizontal from (r,c-1) pathcost_t cost = m_m->getPathCost(r, c-1) + straightIncrement; - if ((min < 0) || (cost < min)) { + if ((min == INVALID_PATHCOST) || (cost < min)) { min = cost; err.prevCost = m_m->getPathCost(r, c-1); dir = AdvanceOther;