mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-08 23:23:01 -06:00
Performance : Use map to speed up search
This commit is contained in:
parent
bb40453ae4
commit
abd4b7c769
@ -314,6 +314,7 @@ size_t RigCaseCellResultsData::findOrCreateScalarResultIndex( const RigEclipseRe
|
||||
RigEclipseResultInfo resInfo( resVarAddr, needsToBeStored, false, scalarResultIndex );
|
||||
|
||||
m_resultInfos.push_back( resInfo );
|
||||
m_addressToResultIndexMap[resVarAddr] = scalarResultIndex;
|
||||
|
||||
// Create statistics calculator and add statistics cache object
|
||||
// Todo: Move to a "factory" method
|
||||
@ -730,6 +731,7 @@ void RigCaseCellResultsData::clearAllResults()
|
||||
{
|
||||
m_cellScalarResults.clear();
|
||||
m_resultInfos.clear();
|
||||
m_addressToResultIndexMap.clear();
|
||||
m_statisticsDataCache.clear();
|
||||
}
|
||||
|
||||
@ -3256,13 +3258,10 @@ size_t RigCaseCellResultsData::findScalarResultIndexFromAddress( const RigEclips
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<RigEclipseResultInfo>::const_iterator it;
|
||||
for ( it = m_resultInfos.begin(); it != m_resultInfos.end(); ++it )
|
||||
auto index = m_addressToResultIndexMap.find( resVarAddr );
|
||||
if ( index != m_addressToResultIndexMap.end() )
|
||||
{
|
||||
if ( it->eclipseResultAddress() == resVarAddr )
|
||||
{
|
||||
return it->gridScalarResultIndex();
|
||||
}
|
||||
return index->second;
|
||||
}
|
||||
|
||||
return cvf::UNDEFINED_SIZE_T;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <QDateTime>
|
||||
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class RifReaderInterface;
|
||||
@ -199,8 +200,9 @@ private:
|
||||
|
||||
std::vector<std::vector<std::vector<double>>> m_cellScalarResults; ///< Scalar results on the complete reservoir for
|
||||
///< each Result index (ResultVariable) and timestep
|
||||
cvf::Collection<RigStatisticsDataCache> m_statisticsDataCache;
|
||||
std::vector<RigEclipseResultInfo> m_resultInfos;
|
||||
cvf::Collection<RigStatisticsDataCache> m_statisticsDataCache;
|
||||
std::vector<RigEclipseResultInfo> m_resultInfos;
|
||||
std::map<RigEclipseResultAddress, size_t> m_addressToResultIndexMap;
|
||||
|
||||
RigMainGrid* m_ownerMainGrid;
|
||||
RigEclipseCaseData* m_ownerCaseData;
|
||||
|
Loading…
Reference in New Issue
Block a user