From: mpv Date: Fri, 7 Jul 2017 05:56:50 +0000 (+0300) Subject: Memory usage optimization for Builders on big tags creation (like Partition). X-Git-Tag: V_2.7.2RC~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=69b1171c5226d775e0f5e3ff241d40b47c09244c;p=modules%2Fshaper.git Memory usage optimization for Builders on big tags creation (like Partition). --- diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index 383661d86..9c143aef8 100755 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -251,9 +251,9 @@ void Model_BodyBuilder::storeWithoutNaming(const std::shared_ptr void Model_BodyBuilder::clean() { - std::vector::iterator aBuilder = myBuilders.begin(); + std::map::iterator aBuilder = myBuilders.begin(); for(; aBuilder != myBuilders.end(); aBuilder++) - delete *aBuilder; + delete aBuilder->second; myBuilders.clear(); } @@ -264,17 +264,13 @@ Model_BodyBuilder::~Model_BodyBuilder() TNaming_Builder* Model_BodyBuilder::builder(const int theTag) { - if (myBuilders.size() <= (unsigned int)theTag) { - myBuilders.insert(myBuilders.end(), theTag - myBuilders.size() + 1, NULL); - } - if (!myBuilders[theTag]) { + std::map::iterator aFind = myBuilders.find(theTag); + if (aFind == myBuilders.end()) { std::shared_ptr aData = std::dynamic_pointer_cast(data()); myBuilders[theTag] = new TNaming_Builder(aData->shapeLab().FindChild(theTag)); - //TCollection_AsciiString entry;// - //TDF_Tool::Entry(aData->shapeLab().FindChild(theTag), entry); - //cout << "Label = " <second; } void Model_BodyBuilder::buildName(const int theTag, const std::string& theName) diff --git a/src/Model/Model_BodyBuilder.h b/src/Model/Model_BodyBuilder.h index f295e0864..983c03a75 100755 --- a/src/Model/Model_BodyBuilder.h +++ b/src/Model/Model_BodyBuilder.h @@ -36,9 +36,9 @@ class TNaming_Builder; */ class Model_BodyBuilder : public ModelAPI_BodyBuilder { - /// builders that tores the naming history: one per label to allow store several shapes to one + /// builders that store the naming history: one per label to allow store several shapes to one /// label; index in vector corresponds to the label tag - std::vector myBuilders; + std::map myBuilders; public: /// Stores the shape (called by the execution method). MODEL_EXPORT virtual void store(const std::shared_ptr& theShape,