From kde-commits Wed Jul 31 22:34:24 2013 From: Thibaut Gridel Date: Wed, 31 Jul 2013 22:34:24 +0000 To: kde-commits Subject: [marble] src/lib: PlacemarkLayout: optimise for label-less placemarks Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=137531007201331 Git commit b532c4bbb057d9120f94205bff5605c6535230c5 by Thibaut Gridel. Committed on 31/07/2013 at 22:33. Pushed by tgridel into branch 'master'. PlacemarkLayout: optimise for label-less placemarks roomForLabel is indeed the culprit: - it didn't scale as it wrongly iterated all placemarks - it isn't needed once we know a placemark doesn't have text BUG: 322783 M +19 -14 src/lib/PlacemarkLayout.cpp http://commits.kde.org/marble/b532c4bbb057d9120f94205bff5605c6535230c5 diff --git a/src/lib/PlacemarkLayout.cpp b/src/lib/PlacemarkLayout.cpp index 491aeb6..4c322d9 100644 --- a/src/lib/PlacemarkLayout.cpp +++ b/src/lib/PlacemarkLayout.cpp @@ -542,10 +542,13 @@ bool PlacemarkLayout::layoutPlacemark( const GeoDataP= lacemark *placemark, qreal // If there's not enough space free don't add a VisiblePlacemark here. const GeoDataStyle* style =3D placemark->style(); = - QRectF labelRect =3D roomForLabel( style, x, y, placemark->name() ); - - if ( labelRect.isNull() ) - return false; + QRectF labelRect; + if( !placemark->name().isEmpty() ) { + labelRect =3D roomForLabel( style, x, y, placemark->name() ); + if ( labelRect.isNull() ) { + return false; + } + } = // Find the corresponding visible placemark VisiblePlacemark *mark =3D m_visiblePlacemarks.value( placemark ); @@ -566,14 +569,16 @@ bool PlacemarkLayout::layoutPlacemark( const GeoDataP= lacemark *placemark, qreal y - qRound( hotSpot.y() ) ) ); mark->setLabelRect( labelRect ); = - // Add the current placemark to the matching row and its - // direct neighbors. - int idx =3D y / m_maxLabelHeight; - if ( idx - 1 >=3D 0 ) - m_rowsection[ idx - 1 ].append( mark ); - m_rowsection[ idx ].append( mark ); - if ( idx + 1 < m_rowsection.size() ) - m_rowsection[ idx + 1 ].append( mark ); + if ( !labelRect.isEmpty() ) { + // Add the current placemark to the matching row and its + // direct neighbors. + int idx =3D y / m_maxLabelHeight; + if ( idx - 1 >=3D 0 ) + m_rowsection[ idx - 1 ].append( mark ); + m_rowsection[ idx ].append( mark ); + if ( idx + 1 < m_rowsection.size() ) + m_rowsection[ idx + 1 ].append( mark ); + } = m_paintOrder.append( mark ); m_labelArea +=3D labelRect.width() * labelRect.height(); @@ -640,8 +645,8 @@ QRectF PlacemarkLayout::roomForLabel( const GeoDataStyl= e * style, labelRect.moveTo( xpos, ypos ); = // Check if there is another label or symbol that overlaps. - QVector::const_iterator beforeItEnd =3D m_p= aintOrder.constEnd(); - for ( QVector::ConstIterator beforeIt =3D m= _paintOrder.constBegin(); + QVector::const_iterator beforeItEnd =3D cur= rentsec.constEnd(); + for ( QVector::ConstIterator beforeIt =3D c= urrentsec.constBegin(); beforeIt !=3D beforeItEnd; ++beforeIt ) { if ( labelRect.intersects( (*beforeIt)->labelRect()) ) {