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