Salome HOME
Optimize performance of mesh deletion upon hyp modification
[modules/smesh.git] / src / SMDS / SMDS_MeshIDFactory.cxx
index 74e5e401df8fe78adc9c8fc3cef9dcd840ae3439..cc765d8665910c5424f82372544ec8acaa6ecd03 100644 (file)
@@ -50,8 +50,8 @@ int SMDS_MeshIDFactory::GetFreeID()
   else
   {
     set<int>::iterator i = myPoolOfID.begin();
-    newid = *i;//myPoolOfID.top();
-    myPoolOfID.erase( i );//myPoolOfID.pop();
+    newid = *i;
+    myPoolOfID.erase( i );
   }
   return newid;
 }
@@ -77,11 +77,13 @@ void SMDS_MeshIDFactory::ReleaseID(int ID, int vtkId)
         while ( i != myPoolOfID.begin() && myMaxID == *i ) {
           --myMaxID; --i;
         }
-        if ( myMaxID == *i )
+        if ( myMaxID == *i ) {
           --myMaxID; // begin of myPoolOfID reached
-        else
-          ++i;
-        myPoolOfID.erase( i, myPoolOfID.end() );
+          myPoolOfID.clear();
+        }
+        else if ( myMaxID < ID-1 ) {
+          myPoolOfID.erase( ++i, myPoolOfID.end() );
+        }
       }
     }
   }