From: caremoli Date: Mon, 3 Jan 2011 18:08:30 +0000 (+0000) Subject: CCAR: some optimisations for SALOMEDS X-Git-Tag: Start_BR_19998_21191~102 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=65d052d8f130bdad959faec4316b71661ac199ea;p=modules%2Fkernel.git CCAR: some optimisations for SALOMEDS --- diff --git a/src/DF/DF_Label.cxx b/src/DF/DF_Label.cxx index 56b1624a7..ef53926e1 100644 --- a/src/DF/DF_Label.cxx +++ b/src/DF/DF_Label.cxx @@ -44,7 +44,7 @@ DF_Label DF_Label::Label(const DF_Label& theLabel, const std::string& theEntry, char* cc = (char*)theEntry.c_str(); int n = 0; - std::vector tags; + int i=0; while (*cc != '\0') { while ( *cc >= '0' && *cc <= '9') { @@ -52,21 +52,20 @@ DF_Label DF_Label::Label(const DF_Label& theLabel, const std::string& theEntry, ++cc; } if (*cc == ':' || *cc == '\0') { - tags.push_back(n); + if(i>0) + { + if(aLabel.IsNull())break; + aLabel = aLabel.FindChild(n, isCreated); + } + i++; n = 0; if (*cc != '\0') ++cc; } else { - tags.clear(); - break; + return DF_Label(); } } - if(!tags.size()) return DF_Label(); - - for(int i = 1, len = tags.size(); !aLabel.IsNull() && i_attributes.find(theID) == _node->_attributes.end()) return NULL; - return _node->_attributes[theID]; + std::map< std::string, DF_Attribute* >::iterator it=_node->_attributes.find(theID); + if(it == _node->_attributes.end()) return NULL; + return it->second; + } //Returns true if there is an Attribute with given ID on this Label. @@ -376,29 +377,31 @@ DF_Label DF_Label::NewChild() //Returns a string entry of this Label std::string DF_Label::Entry() const { - std::string entry = ""; - std::vector vi; DF_LabelNode* father = this->_node; - while(father) { - vi.push_back(father->_tag); - father = father->_father; - } - - int len = vi.size(); - if(len == 1) { - entry = "0:"; - } - else { - char buffer[128]; - for(int i = len-1; i>=0; i--) { - int tag = vi[i]; - sprintf(buffer, "%d", tag); - entry+=std::string(buffer); - if(i) entry += ":"; + if(!father->_father)return "0:"; + int tag; + char buff[128]; + char* wstr= buff; + char* str = buff; + + while(father) + { + tag=father->_tag; + do{ + // Conversion. Number is reversed. + *wstr++ = '0' + (tag % 10); + }while(tag /= 10); + father = father->_father; + if(father)*wstr++ = ':'; } - } + *wstr-- = '\0'; + + //reverse the buffer + char aux; + while (wstr > str) + aux = *wstr, *wstr-- = *str, *str++ = aux; - return entry; + return buff; } bool DF_Label::IsEqual(const DF_Label& theLabel) diff --git a/src/SALOMEDS/SALOMEDS_Attributes.hxx b/src/SALOMEDS/SALOMEDS_Attributes.hxx index 66abd78c9..b4d116727 100644 --- a/src/SALOMEDS/SALOMEDS_Attributes.hxx +++ b/src/SALOMEDS/SALOMEDS_Attributes.hxx @@ -92,7 +92,7 @@ #include "SALOMEDS_AttributeParameter_i.hxx" #include "SALOMEDS_AttributeString_i.hxx" -#define __CreateCORBAAttribute(CORBA_Name) if (strcmp(aTypeOfAttribute, #CORBA_Name) == 0) { \ +#define __CreateCORBAAttribute(CORBA_Name) else if (strcmp(aTypeOfAttribute, #CORBA_Name) == 0) { \ SALOMEDSImpl_##CORBA_Name* A = dynamic_cast(theAttr); \ SALOMEDS_##CORBA_Name##_i* Attr = new SALOMEDS_##CORBA_Name##_i(A, theOrb); \ attr_servant = Attr; \ @@ -101,6 +101,7 @@ #define __CreateGenericCORBAAttribute \ + if(0){} \ __CreateCORBAAttribute(AttributeReal) \ __CreateCORBAAttribute(AttributeInteger) \ __CreateCORBAAttribute(AttributeSequenceOfReal) \ diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index bf2b3b858..0e4a3db6f 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -344,8 +344,9 @@ SALOMEDSImpl_SObject SALOMEDSImpl_Study::FindObjectIOR(const std::string& anObje SALOMEDSImpl_SObject aResult ; // searching in the datamap for optimization - if (myIORLabels.find(anObjectIOR) != myIORLabels.end()) { - aResult = GetSObject(myIORLabels[anObjectIOR]); + std::map::iterator it=myIORLabels.find(anObjectIOR); + if (it != myIORLabels.end()) { + aResult = GetSObject(it->second); // 11 oct 2002: forbidden attributes must be checked here if (!aResult.GetLabel().IsAttribute(SALOMEDSImpl_AttributeIOR::GetID())) { myIORLabels.erase(anObjectIOR); @@ -966,16 +967,18 @@ void SALOMEDSImpl_Study::UpdateIORLabelMap(const std::string& anIOR,const std::s { _errorCode = ""; DF_Label aLabel = DF_Label::Label(_doc->Main(), anEntry, true); - if (myIORLabels.find(anIOR) != myIORLabels.end()) myIORLabels.erase(anIOR); + std::map::iterator it=myIORLabels.find(anIOR); + if (it != myIORLabels.end()) myIORLabels.erase(it); myIORLabels[anIOR] = aLabel; } void SALOMEDSImpl_Study::DeleteIORLabelMapItem(const std::string& anIOR) { - if (myIORLabels.find(anIOR) != myIORLabels.end()) + std::map::iterator it=myIORLabels.find(anIOR); + if (it != myIORLabels.end()) { //remove the ior entry and decref the genericobj (if it's one) - myIORLabels.erase(anIOR); + myIORLabels.erase(it); } } @@ -1131,8 +1134,9 @@ SALOMEDSImpl_SComponent SALOMEDSImpl_Study::GetSComponent(const DF_Label& theLab SALOMEDSImpl_SObject SALOMEDSImpl_Study::GetSObject(const std::string& theEntry) { SALOMEDSImpl_SObject aSO; - if(_mapOfSO.find(theEntry) != _mapOfSO.end()) - aSO = _mapOfSO[theEntry]; + std::map::iterator it=_mapOfSO.find(theEntry); + if(it != _mapOfSO.end()) + aSO = it->second; else { DF_Label aLabel = DF_Label::Label(_doc->Main(), theEntry); aSO = SALOMEDSImpl_SObject(aLabel);