From 69a1901904c6cf5f2c5172e91b449fe975c59d73 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 14 Sep 2020 20:17:20 +0200 Subject: [PATCH] #6491 Fix range iterators which was creating data copies (clang10 warnings). --- ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp | 4 ++-- ApplicationCode/FileInterface/RifElementPropertyReader.cpp | 2 +- ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp | 2 +- ApplicationCode/FileInterface/RifReaderFmuRft.h | 4 ++-- .../FileInterface/RifWellPathFormationReader.cpp | 2 +- ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp | 4 ++-- ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp | 2 +- .../ProjectDataModel/RimMudWeightWindowParameters.cpp | 2 +- .../ProjectDataModel/Summary/RimEnsembleCurveSet.cpp | 2 +- .../ReservoirDataModel/RigWellPathFormations.cpp | 6 +++--- ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp | 2 +- .../UserInterface/RiuExpressionContextMenuManager.cpp | 2 +- ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp | 6 +++--- 13 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index 7719f87275..089c5a7b5f 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -749,7 +749,7 @@ void RifEclipseInputFileTools::saveFaults( QTextStream& stream, stream << "-- Name I1 I2 J1 J2 K1 K2 Face ( I/J/K )" << endl; const cvf::Collection& faults = mainGrid->faults(); - for ( const auto fault : faults ) + for ( const auto& fault : faults ) { if ( fault->name() != RiaDefines::undefinedGridFaultName() && fault->name() != RiaDefines::undefinedGridFaultWithInactiveName() ) @@ -1281,7 +1281,7 @@ qint64 RifEclipseInputFileTools::findKeyword( const QString& keyword, QFile& fil bool RifEclipseInputFileTools::isValidDataKeyword( const QString& keyword ) { const std::vector& keywordsToSkip = RifEclipseInputFileTools::invalidPropertyDataKeywords(); - for ( const QString keywordToSkip : keywordsToSkip ) + for ( const QString& keywordToSkip : keywordsToSkip ) { if ( keywordToSkip == keyword.toUpper() ) { diff --git a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp index 163393abea..12c6651f6a 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp +++ b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp @@ -77,7 +77,7 @@ std::vector RifElementPropertyReader::scalarElementFields() const { std::vector fields; - for ( const std::pair& field : m_fieldsMetaData ) + for ( const std::pair& field : m_fieldsMetaData ) { fields.push_back( field.first ); } diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp index e10a47c7f8..4efb9dfc40 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp @@ -729,7 +729,7 @@ void RifReaderEclipseSummary::ValuesCache::markAddressForPurge( const RifEclipse //-------------------------------------------------------------------------------------------------- void RifReaderEclipseSummary::ValuesCache::purgeData() { - for ( const auto purgeAddr : m_purgeList ) + for ( const auto& purgeAddr : m_purgeList ) { m_cachedValues.erase( purgeAddr ); } diff --git a/ApplicationCode/FileInterface/RifReaderFmuRft.h b/ApplicationCode/FileInterface/RifReaderFmuRft.h index df50b53566..fe45d3d54a 100644 --- a/ApplicationCode/FileInterface/RifReaderFmuRft.h +++ b/ApplicationCode/FileInterface/RifReaderFmuRft.h @@ -88,8 +88,8 @@ public: void load(); private: - typedef std::pair WellObservationPair; - typedef std::map WellObservationMap; + typedef std::pair WellObservationPair; + typedef std::map WellObservationMap; WellObservationMap loadWellDates( QDir& dir, QString* errorMsg ); static bool readTxtFile( const QString& txtFileName, QString* errorMsg, WellObservationSet* wellObservationSet ); diff --git a/ApplicationCode/FileInterface/RifWellPathFormationReader.cpp b/ApplicationCode/FileInterface/RifWellPathFormationReader.cpp index 2097dc9d36..5120df49e0 100644 --- a/ApplicationCode/FileInterface/RifWellPathFormationReader.cpp +++ b/ApplicationCode/FileInterface/RifWellPathFormationReader.cpp @@ -118,7 +118,7 @@ std::map> formations[wellNames[i]].push_back( formation ); } - for ( const std::pair>& formation : formations ) + for ( const std::pair>& formation : formations ) { cvf::ref wellPathFormations = new RigWellPathFormations( formation.second, filePath, formation.first ); diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp index 1d9527d14a..b3837a35be 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp @@ -1193,14 +1193,14 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps( QString dateFormatString; { std::vector allTimeSteps; - for ( const std::pair>& timeStepPair : timestepsToShowWithSources ) + for ( const std::pair>& timeStepPair : timestepsToShowWithSources ) { allTimeSteps.push_back( timeStepPair.first ); } dateFormatString = RiaQDateTimeTools::createTimeFormatStringFromDates( allTimeSteps ); } - for ( const std::pair>& timeStepPair : timestepsToShowWithSources ) + for ( const std::pair>& timeStepPair : timestepsToShowWithSources ) { QString optionText = RiaQDateTimeTools::toStringUsingApplicationLocale( timeStepPair.first, dateFormatString ); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index c46e7f0ff1..0a7409a5d2 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -1230,7 +1230,7 @@ QList RimGeoMechCase::calculateValueOptions( const caf:: std::map addressesInFile = geoMechData()->femPartResults()->addressesInElementPropertyFiles( paths ); - for ( const std::string elementProperty : elementProperties ) + for ( const std::string& elementProperty : elementProperties ) { QString result = QString::fromStdString( elementProperty ); QString filename = findFileNameForElementProperty( elementProperty, addressesInFile ); diff --git a/ApplicationCode/ProjectDataModel/RimMudWeightWindowParameters.cpp b/ApplicationCode/ProjectDataModel/RimMudWeightWindowParameters.cpp index 0df9a621dc..a5fdeaa5d8 100644 --- a/ApplicationCode/ProjectDataModel/RimMudWeightWindowParameters.cpp +++ b/ApplicationCode/ProjectDataModel/RimMudWeightWindowParameters.cpp @@ -612,7 +612,7 @@ QList std::map addressesInFile = geoMechCase->geoMechData()->femPartResults()->addressesInElementPropertyFiles( paths ); - for ( const std::string elementProperty : elementProperties ) + for ( const std::string& elementProperty : elementProperties ) { QString result = QString::fromStdString( elementProperty ); QString filename = geoMechCase->findFileNameForElementProperty( elementProperty, addressesInFile ); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 5e604d3215..d8e3c6d397 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -1086,7 +1086,7 @@ void RimEnsembleCurveSet::showCurves( bool show ) //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSet::markCachedDataForPurge() { - for ( const auto curve : m_curves ) + for ( const auto& curve : m_curves ) { curve->markCachedDataForPurge(); } diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp index 8334df080b..14cda8888b 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp @@ -217,7 +217,7 @@ void RigWellPathFormations::evaluateFormations( const std::vector& uniqueDepth : tempMakeVectorUniqueOnDepth ) + for ( const std::pair& uniqueDepth : tempMakeVectorUniqueOnDepth ) { depths->push_back( uniqueDepth.first ); names->push_back( uniqueDepth.second.name ); @@ -268,7 +268,7 @@ void RigWellPathFormations::evaluateFluids( const std::vector& depthAndFormation : uniqueListMaker ) + for ( const std::pair& depthAndFormation : uniqueListMaker ) { depths->push_back( depthAndFormation.first ); names->push_back( depthAndFormation.second ); @@ -313,7 +313,7 @@ std::vector RigWellPathFormations::format { std::vector formationLevels; - for ( const std::pair& formationLevel : m_formationsLevelsPresent ) + for ( const std::pair& formationLevel : m_formationsLevelsPresent ) { formationLevels.push_back( formationLevel.first ); } diff --git a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp index 232bb88513..3770436917 100644 --- a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp @@ -1321,7 +1321,7 @@ public: for ( size_t timeStep : requestedTimesteps ) { - for ( const std::pair selectedCell : selectedCells ) + for ( const std::pair& selectedCell : selectedCells ) { cvf::ref resultAccessor = RigResultAccessorFactory::createFromResultAddress( rimCase->eclipseCaseData(), diff --git a/ApplicationCode/UserInterface/RiuExpressionContextMenuManager.cpp b/ApplicationCode/UserInterface/RiuExpressionContextMenuManager.cpp index 90c1334b52..6521c17753 100644 --- a/ApplicationCode/UserInterface/RiuExpressionContextMenuManager.cpp +++ b/ApplicationCode/UserInterface/RiuExpressionContextMenuManager.cpp @@ -52,7 +52,7 @@ void RiuExpressionContextMenuManager::slotMenuItems( QPoint point ) { QMenu menu; - for ( const std::pair>& subMenuPair : MENU_MAP ) + for ( const std::pair>& subMenuPair : MENU_MAP ) { QMenu* subMenu = menu.addMenu( subMenuPair.first ); diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index 72ac2aab7e..2ea6ee8fa6 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -345,7 +345,7 @@ void RiuMohrsCirclePlot::addorUpdateEnvelopeCurve( const cvf::Vec3f& principals, //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::deleteEnvelopes() { - for ( const std::pair& envelope : m_envolopePlotItems ) + for ( const std::pair& envelope : m_envolopePlotItems ) { envelope.second->detach(); delete envelope.second; @@ -643,7 +643,7 @@ void RiuMohrsCirclePlot::idealAxesEndPoints( double* xMin, double* xMax, double* *yMax = -HUGE_VAL; double maxYEnvelope = -HUGE_VAL; - for ( const std::pair& envelope : m_envolopePlotItems ) + for ( const std::pair& envelope : m_envolopePlotItems ) { double tempMax = envelope.second->maxYValue(); if ( tempMax > maxYEnvelope ) @@ -655,7 +655,7 @@ void RiuMohrsCirclePlot::idealAxesEndPoints( double* xMin, double* xMax, double* *yMax = std::max( maxYEnvelope, 1.2 * largestCircleRadiusInPlot() ); double minXEvelope = HUGE_VAL; - for ( const std::pair& envelope : m_envolopePlotItems ) + for ( const std::pair& envelope : m_envolopePlotItems ) { double tempMin = envelope.second->minXValue(); if ( tempMin < minXEvelope )