Using const-refs instead of copies when iterating vectors

This commit is contained in:
DennisOSRM 2013-01-06 12:59:36 +01:00
parent 06c22a478f
commit e70adbb1cb
3 changed files with 5 additions and 5 deletions

View File

@ -179,7 +179,7 @@ public:
double dist = std::numeric_limits<double>::max(); double dist = std::numeric_limits<double>::max();
double r, tmpDist; double r, tmpDist;
BOOST_FOREACH(_GridEdge candidate, candidates) { BOOST_FOREACH(const _GridEdge & candidate, candidates) {
if(candidate.belongsToTinyComponent && ignoreTinyComponents) if(candidate.belongsToTinyComponent && ignoreTinyComponents)
continue; continue;
r = 0.; r = 0.;
@ -266,7 +266,7 @@ public:
} }
_Coordinate tmp; _Coordinate tmp;
double dist = (std::numeric_limits<double>::max)(); double dist = (std::numeric_limits<double>::max)();
BOOST_FOREACH(_GridEdge candidate, candidates) { BOOST_FOREACH(const _GridEdge & candidate, candidates) {
double r = 0.; double r = 0.;
double tmpDist = ComputeDistance(startCoord, candidate.startCoord, candidate.targetCoord, tmp, &r); double tmpDist = ComputeDistance(startCoord, candidate.startCoord, candidate.targetCoord, tmp, &r);
if(tmpDist < dist) { if(tmpDist < dist) {
@ -312,7 +312,7 @@ private:
cellMap.insert(insertionVector.begin(), insertionVector.end()); cellMap.insert(insertionVector.begin(), insertionVector.end());
} }
inline bool DoubleEpsilonCompare(const double d1, const double d2) { inline bool DoubleEpsilonCompare(const double d1, const double d2) const {
return (std::fabs(d1 - d2) < FLT_EPSILON); return (std::fabs(d1 - d2) < FLT_EPSILON);
} }

View File

@ -46,7 +46,7 @@ public:
convertInternalLatLonToString(phantomNodes.startPhantom.location.lon, tmp); convertInternalLatLonToString(phantomNodes.startPhantom.location.lon, tmp);
reply.content += "lon=\"" + tmp + "\"></rtept>"; reply.content += "lon=\"" + tmp + "\"></rtept>";
BOOST_FOREACH(_PathData pathData, rawRoute.computedShortestPath) { BOOST_FOREACH(const _PathData & pathData, rawRoute.computedShortestPath) {
sEngine.GetCoordinatesForNodeID(pathData.node, current); sEngine.GetCoordinatesForNodeID(pathData.node, current);
convertInternalLatLonToString(current.lat, tmp); convertInternalLatLonToString(current.lat, tmp);

View File

@ -246,7 +246,7 @@ public:
reply.content += "}"; reply.content += "}";
} }
void GetRouteNames(std::vector<Segment> & shortestSegments, std::vector<Segment> & alternativeSegments, SearchEngineT &sEngine, RouteNames & routeNames) { void GetRouteNames(std::vector<Segment> & shortestSegments, std::vector<Segment> & alternativeSegments, const SearchEngineT &sEngine, RouteNames & routeNames) {
/*** extract names for both alternatives ***/ /*** extract names for both alternatives ***/
Segment shortestSegment1, shortestSegment2; Segment shortestSegment1, shortestSegment2;