Skip to content

Commit

Permalink
Use QHash instead of QMap with pointer key
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 20, 2019
1 parent a882ece commit fd68d8e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/core/layertree/qgslayertreemodel.cpp
Expand Up @@ -1516,8 +1516,7 @@ QList<QgsLayerTreeModelLegendNode *> QgsLayerTreeModel::layerOriginalLegendNodes

QgsLayerTreeModelLegendNode *QgsLayerTreeModel::findLegendNode( const QString &layerId, const QString &ruleKey ) const
{
QMap<QgsLayerTreeLayer *, LayerLegendData>::const_iterator it = mLegend.constBegin();
for ( ; it != mLegend.constEnd(); ++it )
for ( auto it = mLegend.constBegin(); it != mLegend.constEnd(); ++it )
{
QgsLayerTreeLayer *layer = it.key();
if ( layer->layerId() == layerId )
Expand Down Expand Up @@ -1557,8 +1556,7 @@ void QgsLayerTreeModel::invalidateLegendMapBasedData()

std::unique_ptr<QgsRenderContext> context( createTemporaryRenderContext() );

const auto constMLegend = mLegend;
for ( const LayerLegendData &data : constMLegend )
for ( const LayerLegendData &data : qgis::as_const( mLegend ) )
{
QList<QgsSymbolLegendNode *> symbolNodes;
QMap<QString, int> widthMax;
Expand Down
2 changes: 1 addition & 1 deletion src/core/layertree/qgslayertreemodel.h
Expand Up @@ -423,7 +423,7 @@ class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel
QMap<QString, QString> mLayerStyleOverrides;

//! Per layer data about layer's legend nodes
QMap<QgsLayerTreeLayer *, LayerLegendData> mLegend;
QHash<QgsLayerTreeLayer *, LayerLegendData> mLegend;

QFont mFontLayer;
QFont mFontGroup;
Expand Down

0 comments on commit fd68d8e

Please sign in to comment.