summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-10-03 06:17:33 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-10-03 06:19:27 (GMT)
commit9636c8c18d6166dbe10898f7ba5267bfde053824 (patch)
tree220078cc3d0ed9b6e342989fd39428aef498ab89
parent35c33f18b7d50834a78cfbdb11d946040c501ea2 (diff)
Reduce number of comparisons from 2n to 1.5n in average.
-rw-r--r--src/lib/marble/geodata/data/GeoDataLatLonAltBox.cpp9
-rw-r--r--src/lib/marble/geodata/data/GeoDataLatLonBox.cpp7
2 files changed, 11 insertions, 5 deletions
diff --git a/src/lib/marble/geodata/data/GeoDataLatLonAltBox.cpp b/src/lib/marble/geodata/data/GeoDataLatLonAltBox.cpp
index 54a25bc..04c9266 100644
--- a/src/lib/marble/geodata/data/GeoDataLatLonAltBox.cpp
+++ b/src/lib/marble/geodata/data/GeoDataLatLonAltBox.cpp
@@ -243,9 +243,12 @@ GeoDataLatLonAltBox GeoDataLatLonAltBox::fromLineString( const GeoDataLineStrin
// Get coordinates and normalize them to the desired range.
const qreal altitude = (it)->altitude();
- // Determining the maximum and minimum latitude
- if ( altitude > maxAltitude ) maxAltitude = altitude;
- if ( altitude < minAltitude ) minAltitude = altitude;
+ // Determining the maximum and minimum altitude
+ if ( altitude > maxAltitude ) {
+ maxAltitude = altitude;
+ } else if ( altitude < minAltitude ) {
+ minAltitude = altitude;
+ }
}
temp.setMinAltitude( minAltitude );
diff --git a/src/lib/marble/geodata/data/GeoDataLatLonBox.cpp b/src/lib/marble/geodata/data/GeoDataLatLonBox.cpp
index c0419ad..073ac9b 100644
--- a/src/lib/marble/geodata/data/GeoDataLatLonBox.cpp
+++ b/src/lib/marble/geodata/data/GeoDataLatLonBox.cpp
@@ -716,8 +716,11 @@ GeoDataLatLonBox GeoDataLatLonBox::fromLineString( const GeoDataLineString& lin
GeoDataCoordinates::normalizeLonLat( lon, lat );
// Determining the maximum and minimum latitude
- if ( lat > north ) north = lat;
- if ( lat < south ) south = lat;
+ if ( lat > north ) {
+ north = lat;
+ } else if ( lat < south ) {
+ south = lat;
+ }
currentSign = ( lon < 0 ) ? -1 : +1;