summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-10-02 20:37:59 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-10-02 20:40:18 (GMT)
commit35c33f18b7d50834a78cfbdb11d946040c501ea2 (patch)
tree1565b02ce74f375164b9b4e2cffacc706e027ab6
parentba2a3c9c6ea54aa00b9ad42f515f2f05c441669f (diff)
Manually implement the default parameter value case for performance
Avoiding the switch has a noticable impact on runtime. It is relevant here because GeoDataCoordinates::longitude() and latitude() are hotspots.
-rw-r--r--src/lib/marble/geodata/data/GeoDataCoordinates.cpp10
-rw-r--r--src/lib/marble/geodata/data/GeoDataCoordinates.h8
2 files changed, 14 insertions, 4 deletions
diff --git a/src/lib/marble/geodata/data/GeoDataCoordinates.cpp b/src/lib/marble/geodata/data/GeoDataCoordinates.cpp
index 9e8d2db..c4b1cdc 100644
--- a/src/lib/marble/geodata/data/GeoDataCoordinates.cpp
+++ b/src/lib/marble/geodata/data/GeoDataCoordinates.cpp
@@ -198,6 +198,11 @@ qreal GeoDataCoordinates::longitude( GeoDataCoordinates::Unit unit ) const
}
}
+qreal GeoDataCoordinates::longitude() const
+{
+ return d->m_lon;
+}
+
qreal GeoDataCoordinates::latitude( GeoDataCoordinates::Unit unit ) const
{
switch ( unit )
@@ -210,6 +215,11 @@ qreal GeoDataCoordinates::latitude( GeoDataCoordinates::Unit unit ) const
}
}
+qreal GeoDataCoordinates::latitude() const
+{
+ return d->m_lat;
+}
+
//static
GeoDataCoordinates::Notation GeoDataCoordinates::defaultNotation()
{
diff --git a/src/lib/marble/geodata/data/GeoDataCoordinates.h b/src/lib/marble/geodata/data/GeoDataCoordinates.h
index e0cdaca..1089124 100644
--- a/src/lib/marble/geodata/data/GeoDataCoordinates.h
+++ b/src/lib/marble/geodata/data/GeoDataCoordinates.h
@@ -190,8 +190,8 @@ class GEODATA_EXPORT GeoDataCoordinates
* (default for Radian: north pole at pi/2, southpole at -pi/2)
* @return longitude
*/
- qreal longitude( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian )
- const;
+ qreal longitude(GeoDataCoordinates::Unit unit) const;
+ qreal longitude() const;
/**
* @brief retrieves the latitude of the GeoDataCoordinates object
@@ -200,8 +200,8 @@ class GEODATA_EXPORT GeoDataCoordinates
* (default for Radian: north pole at pi/2, southpole at -pi/2)
* @return latitude
*/
- qreal latitude( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian )
- const;
+ qreal latitude( GeoDataCoordinates::Unit unit ) const;
+ qreal latitude() const;
/**
* @brief set the longitude in a GeoDataCoordinates object