mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-31 17:17:50 -05:00
Avoid small allocation on every read of data from resdata
This commit is contained in:
1 parent
f6cd02a6c1
commit
ea06cdc291
1 file changed
+7
-6
@@ -290,14 +290,15 @@ std::pair<bool, std::vector<double>> RifEclEclipseSummary::values( const RifEcli
|
|||||||
const ecl::smspec_node& ertSumVarNode = ecl_smspec_iget_node_w_node_index( m_ecl_SmSpec, variableIndex );
|
const ecl::smspec_node& ertSumVarNode = ecl_smspec_iget_node_w_node_index( m_ecl_SmSpec, variableIndex );
|
||||||
int paramsIndex = ertSumVarNode.get_params_index();
|
int paramsIndex = ertSumVarNode.get_params_index();
|
||||||
|
|
||||||
double_vector_type* dataValues = ecl_sum_alloc_data_vector( m_ecl_sum, paramsIndex, false );
|
// Use data access without memory allocation. Previous implementation used ecl_sum_alloc_data_vector()
|
||||||
|
// Related to https://github.com/OPM/ResInsight/issues/13064
|
||||||
|
int dataLength = ecl_sum_get_data_length( m_ecl_sum );
|
||||||
|
values.reserve( dataLength );
|
||||||
|
|
||||||
if ( dataValues )
|
for ( int timeIndex = 0; timeIndex < dataLength; ++timeIndex )
|
||||||
{
|
{
|
||||||
int dataSize = double_vector_size( dataValues );
|
double value = ecl_sum_iget( m_ecl_sum, timeIndex, paramsIndex );
|
||||||
const double* dataPtr = double_vector_get_const_ptr( dataValues );
|
values.push_back( value );
|
||||||
values.insert( values.end(), dataPtr, dataPtr + dataSize );
|
|
||||||
double_vector_free( dataValues );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user