summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-10-04 20:22:27 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-10-04 20:22:27 (GMT)
commite34e2833aa6a7555bd4fe9aa370686868d1b96f2 (patch)
treeea6da206f433f8d8c3a8499e293c13b1951a72db
parentbfc6837b24018cedba5bbb015ab3efb781a2c106 (diff)
No range check is needed here, and operator[] is faster than at()
-rw-r--r--src/lib/marble/geodata/data/GeoDataLinearRing.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/marble/geodata/data/GeoDataLinearRing.cpp b/src/lib/marble/geodata/data/GeoDataLinearRing.cpp
index 742d558..84789ed 100644
--- a/src/lib/marble/geodata/data/GeoDataLinearRing.cpp
+++ b/src/lib/marble/geodata/data/GeoDataLinearRing.cpp
@@ -67,8 +67,8 @@ bool GeoDataLinearRing::contains( const GeoDataCoordinates &coordinates ) const
int j = points - 1;
for ( int i=0; i<points; ++i ) {
- GeoDataCoordinates const & one = at( i );
- GeoDataCoordinates const & two = at( j );
+ GeoDataCoordinates const & one = operator[]( i );
+ GeoDataCoordinates const & two = operator[]( j );
if ( ( one.longitude() < coordinates.longitude() && two.longitude() >= coordinates.longitude() ) ||
( two.longitude() < coordinates.longitude() && one.longitude() >= coordinates.longitude() ) ) {
@@ -88,9 +88,9 @@ bool GeoDataLinearRing::isClockwise() const
int const n = size();
qreal area = 0;
for ( int i = 1; i < n; ++i ){
- area += ( at( i ).longitude() - at( i - 1 ).longitude() ) * ( at( i ).latitude() + at( i - 1 ).latitude() );
+ area += ( operator[]( i ).longitude() - operator[]( i - 1 ).longitude() ) * ( operator[]( i ).latitude() + operator[]( i - 1 ).latitude() );
}
- area += ( at( 0 ).longitude() - at( n - 1 ).longitude() ) * ( at ( 0 ).latitude() + at( n - 1 ).latitude() );
+ area += ( operator[]( 0 ).longitude() - operator[]( n - 1 ).longitude() ) * ( operator[] ( 0 ).latitude() + operator[]( n - 1 ).latitude() );
return area > 0;
}