Skip to content

Commit

Permalink
Improve performance of PlanarGraph::findEdgeInSameDirection
Browse files Browse the repository at this point in the history
Use the nodeMap instead of performing a complete scan of all edges.
  • Loading branch information
dbaston committed Dec 5, 2019
1 parent adb7ca8 commit 09bdf26
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/geomgraph/PlanarGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,16 @@ Edge*
PlanarGraph::findEdgeInSameDirection(const Coordinate& p0,
const Coordinate& p1)
{
for(size_t i = 0, n = edges->size(); i < n; i++) {
Edge* e = (*edges)[i];
assert(e);
Node* node = getNodeMap()->find(p0);
if (node == nullptr) {
return nullptr;
}

for (const auto& ee : *(node->getEdges())) {
Edge* e = ee->getEdge();

const CoordinateSequence* eCoord = e->getCoordinates();

assert(eCoord);

size_t nCoords = eCoord->size();
Expand Down

0 comments on commit 09bdf26

Please sign in to comment.