From: Anthony Geay Date: Fri, 7 Oct 2022 12:17:11 +0000 (+0200) Subject: [EDF26238] : fix performance on MEDFileMesh::getGroupsOnSpecifiedLev method X-Git-Tag: V9_10_0a1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b25c213605650282751c4b4eca8aceb870efcab4;hp=bfa5b47590efb20b7c5209da180e5038e514a4ff;p=tools%2Fmedcoupling.git [EDF26238] : fix performance on MEDFileMesh::getGroupsOnSpecifiedLev method --- diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index f712e2abd..09bd0ad0d 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; }