From: vsr Date: Fri, 19 Nov 2010 13:26:31 +0000 (+0000) Subject: 0020463: EDF 1099 SMESH: performance regression from V4 to V5 X-Git-Tag: V5_1_5~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0789e9028667713e5869d5ed6a841958febca00c;p=modules%2Fkernel.git 0020463: EDF 1099 SMESH: performance regression from V4 to V5 Patch from Erwan ADAM. --- diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx index 7f63ea527..9cd5b05ca 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include "SALOMEDSImpl_Tool.hxx" @@ -241,24 +243,66 @@ std::vector SALOMEDSImpl_Tool::splitString(const std::string& theVa // purpose : The functions returns a list of substring of initial string // divided by given separator include empty strings //============================================================================ + +std::vector treatRepetation(const std::string& theValue); + +std::vector treatRepetation(const std::string& theValue) +{ + std::vector aResult; + int pos = theValue.find(";*="); + if(pos < 0 ) + { + aResult.push_back(theValue); + return aResult; + } + std::string val(theValue.substr(0, pos)); + std::string suffix(theValue.substr(pos+3)); + int nb; + std::istringstream tmp(suffix); + tmp >> nb; + for(int i=0; i SALOMEDSImpl_Tool::splitStringWithEmpty(const std::string& theValue, char sep) { std::vector aResult; if(theValue[0] == sep ) aResult.push_back(std::string()); int pos = theValue.find(sep); if(pos < 0 ) { - aResult.push_back(theValue); + if(sep == '|') + { + std::vector tmp = treatRepetation(theValue); + std::copy(tmp.begin(), tmp.end(), std::back_insert_iterator< std::vector >(aResult)); + } + else + aResult.push_back(theValue); return aResult; } std::string s = theValue; if(s[0] == sep) s = s.substr(1, s.size()); while((pos = s.find(sep)) >= 0) { - aResult.push_back(s.substr(0, pos)); + if(sep == '|') + { + std::vector tmp = treatRepetation(s.substr(0, pos)); + std::copy(tmp.begin(), tmp.end(), std::back_insert_iterator< std::vector >(aResult)); + } + else + aResult.push_back(s.substr(0, pos)); s = s.substr(pos+1, s.size()); } - if(!s.empty() && s[0] != sep) aResult.push_back(s); + if(!s.empty() && s[0] != sep) { + if(sep == '|') + { + std::vector tmp = treatRepetation(s); + std::copy(tmp.begin(), tmp.end(), std::back_insert_iterator< std::vector >(aResult)); + } + else + aResult.push_back(s); + } if(theValue[theValue.size()-1] == sep) aResult.push_back(std::string()); return aResult;