From b25c213605650282751c4b4eca8aceb870efcab4 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 7 Oct 2022 14:17:11 +0200 Subject: [PATCH] [EDF26238] : fix performance on MEDFileMesh::getGroupsOnSpecifiedLev method --- src/MEDLoader/MEDFileMesh.cxx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index f712e2ab..09bd0ad0 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -534,12 +534,24 @@ std::vector MEDFileMesh::getGroupsOnSpecifiedLev(int meshDimRelToMa { std::vector ret; std::vector allGrps(getGroupsNames()); - for(std::vector::const_iterator it=allGrps.begin();it!=allGrps.end();it++) + const DataArrayIdType *arr=getFamilyFieldAtLevel(meshDimRelToMaxExt); + if(!arr) + return ret; + std::set famIdsInUse(arr->begin(),arr->end()); + // + for(auto it : _groups) + { + for(auto it2 : it.second) { - std::vector levs(getGrpNonEmptyLevelsExt((*it))); - if(std::find(levs.begin(),levs.end(),meshDimRelToMaxExt)!=levs.end()) - ret.push_back(*it); + auto it3 = _families.find( it2 ); + mcIdType famIdToTest = (*it3).second; + if( famIdsInUse.find(famIdToTest) != famIdsInUse.end() ) + { + ret.push_back( it.first ); + break ; + } } + } return ret; } -- 2.30.2