summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-11-05 19:50:22 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-11-05 19:50:22 (GMT)
commitb1b8f0fd691abb789d8464202049de1ac9c85748 (patch)
tree13f5ceea013684236a507fca72cf3316d0e342b4
parentfd19557c891f1867797c81d8e1483078156d0ef7 (diff)
Minor low level optimizations.
-rw-r--r--src/lib/marble/PlacemarkLayout.cpp3
-rw-r--r--src/lib/marble/layers/PlacemarkLayer.cpp21
2 files changed, 11 insertions, 13 deletions
diff --git a/src/lib/marble/PlacemarkLayout.cpp b/src/lib/marble/PlacemarkLayout.cpp
index 9a71cc8..b700d67 100644
--- a/src/lib/marble/PlacemarkLayout.cpp
+++ b/src/lib/marble/PlacemarkLayout.cpp
@@ -365,8 +365,7 @@ QVector<VisiblePlacemark *> PlacemarkLayout::generateLayout( const ViewportParam
for ( int i = 0; i < selectedIndexes.count(); ++i ) {
const QModelIndex index = selectedIndexes.at( i );
- const GeoDataPlacemark *placemark = dynamic_cast<GeoDataPlacemark*>(qvariant_cast<GeoDataObject*>(index.data( MarblePlacemarkModel::ObjectPointerRole ) ));
- Q_ASSERT(placemark);
+ const GeoDataPlacemark *placemark = static_cast<GeoDataPlacemark*>(qvariant_cast<GeoDataObject*>(index.data( MarblePlacemarkModel::ObjectPointerRole ) ));
const GeoDataCoordinates coordinates = placemarkIconCoordinates( placemark );
if ( !coordinates.isValid() ) {
diff --git a/src/lib/marble/layers/PlacemarkLayer.cpp b/src/lib/marble/layers/PlacemarkLayer.cpp
index 2c3c68f..9a4164b 100644
--- a/src/lib/marble/layers/PlacemarkLayer.cpp
+++ b/src/lib/marble/layers/PlacemarkLayer.cpp
@@ -67,7 +67,8 @@ bool PlacemarkLayer::render( GeoPainter *geoPainter, ViewportParams *viewport,
QVector<VisiblePlacemark*>::const_iterator itEnd = visiblePlacemarks.constBegin();
QPainter *const painter = geoPainter;
-
+ bool const repeatableX = viewport->currentProjection()->repeatableX();
+ int const radius4 = 4 * viewport->radius();
while ( visit != itEnd ) {
--visit;
@@ -78,23 +79,21 @@ bool PlacemarkLayer::render( GeoPainter *geoPainter, ViewportParams *viewport,
// when the map is such zoomed out that a given place
// appears many times, we draw one placemark at each
- if (viewport->currentProjection()->repeatableX() ) {
+ if (repeatableX) {
const int symbolX = mark->symbolPosition().x();
const int textX = mark->labelRect().x();
- for ( int i = symbolX % (4 * viewport->radius());
- i <= viewport->width();
- i += 4 * viewport->radius() )
- {
- labelRect.moveLeft(i - symbolX + textX );
- symbolPos.setX( i );
+ for (int i = symbolX % radius4, width = viewport->width(); i <= width; i += radius4) {
+ labelRect.moveLeft(i - symbolX + textX);
+ symbolPos.setX(i);
painter->drawPixmap( symbolPos, mark->symbolPixmap() );
painter->drawPixmap( labelRect, mark->labelPixmap() );
}
- } else { // simple case, one draw per placemark
- painter->drawPixmap( symbolPos, mark->symbolPixmap() );
- painter->drawPixmap( labelRect, mark->labelPixmap() );
+ } else {
+ // simple case, one draw per placemark
+ painter->drawPixmap(symbolPos, mark->symbolPixmap());
+ painter->drawPixmap(labelRect, mark->labelPixmap());
}
}