summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-10-22 13:24:48 (GMT)
committerFriedrich W. H. Kossebau <kossebau@kde.org>2016-11-05 16:47:11 (GMT)
commitff43bd553b58db2928acae9e5cee1ceef0d48152 (patch)
tree15e9759af4eb5813b936a85a9acae4a0788eb8ff
parent1d5a7eb190deaefcd51689aa089aea8ac8667ff4 (diff)
Minor low-level optimizations
- cache function call results outside loop - prefer inexpensive comparisons in lazy evaluations of if clauses - move latLonAltBox() call to commented code section (not needed here)
-rw-r--r--src/lib/marble/projections/CylindricalProjection.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/lib/marble/projections/CylindricalProjection.cpp b/src/lib/marble/projections/CylindricalProjection.cpp
index baa71f1..e08d7fa 100644
--- a/src/lib/marble/projections/CylindricalProjection.cpp
+++ b/src/lib/marble/projections/CylindricalProjection.cpp
@@ -300,18 +300,17 @@ bool CylindricalProjectionPrivate::lineStringToPolygon( const GeoDataLineString
bool isStraight = lineString.latLonAltBox().height() == 0 || lineString.latLonAltBox().width() == 0;
+ Q_Q( const CylindricalProjection );
+ bool const tesselate = lineString.tessellate();
+ bool const isClosed = lineString.isClosed();
while ( itCoords != itEnd )
{
// Optimization for line strings with a big amount of nodes
bool skipNode = (hasDetail ? itCoords->detail() > maximumDetail
- : itCoords != itBegin && isLong && !processingLastNode &&
+ : isLong && !processingLastNode && itCoords != itBegin &&
!viewport->resolves( *itPreviousCoords, *itCoords ) );
if ( !skipNode ) {
-
-
- Q_Q( const CylindricalProjection );
-
q->screenCoordinates( *itCoords, viewport, x, y );
// Initializing variables that store the values of the previous iteration
@@ -324,9 +323,7 @@ bool CylindricalProjectionPrivate::lineStringToPolygon( const GeoDataLineString
// This if-clause contains the section that tessellates the line
// segments of a linestring. If you are about to learn how the code of
// this class works you can safely ignore this section for a start.
-
- if ( lineString.tessellate() && !isStraight) {
-
+ if ( tesselate && !isStraight) {
mirrorCount = tessellateLineSegment( *itPreviousCoords, previousX, previousY,
*itCoords, x, y,
polygons, viewport,
@@ -353,20 +350,19 @@ bool CylindricalProjectionPrivate::lineStringToPolygon( const GeoDataLineString
}
++itCoords;
- if ( itCoords == itEnd && lineString.isClosed() ) {
+ if (isClosed && itCoords == itEnd) {
itCoords = itBegin;
processingLastNode = true;
}
}
- GeoDataLatLonAltBox box = lineString.latLonAltBox();
-
// Closing e.g. in the Antarctica case.
// This code makes the assumption that
// - the first node is located at 180 E
// - and the last node is located at 180 W
// TODO: add a similar pattern in the crossDateLine() code.
/*
+ GeoDataLatLonAltBox box = lineString.latLonAltBox();
if( lineString.isClosed() && box.width() == 2*M_PI ) {
QPolygonF *poly = polygons.last();
if( box.containsPole( NorthPole ) ) {