]> OCCT Git - occt-copy.git/commitdiff
0030835: Possible performance improvements in methods TDF_Label::FindAttribute
authormpv <mpv@opencascade.com>
Mon, 29 Jul 2019 14:11:54 +0000 (17:11 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 2 Aug 2019 12:42:54 +0000 (15:42 +0300)
Make attribute iterator work with pointers to attributes, so, creation of handle on each iteration is avoided.

src/TDF/TDF_AttributeIterator.hxx
src/TDF/TDF_Label.cxx
src/TDF/TDF_Label.hxx

index fa8622c5832eef0b067817e8c741010b696b72f6..dbc6103fd2f1331c30e4faaba3d106bae5ab16d1 100644 (file)
@@ -61,6 +61,9 @@ public:
   Standard_EXPORT   void Next() ;
   inline   Handle(TDF_Attribute) Value() const;
 
+  //! Provides an access to the internal pointer of the current attribute.
+  //! The method has better performance as not-creating handle.
+  inline const TDF_Attribute* PtrValue() const { return myValue; }
 
 protected:
 
index 838a44b347ab10ce6e2364d2d3a36ce07a1f8edc..eba97eb0e501f623a5b211b1b44843c16d2ad7c4 100644 (file)
@@ -60,8 +60,8 @@ Standard_Boolean TDF_Label::FindAttribute
   if (IsNull()) throw Standard_NullObject("A null Label has no attribute.");
   TDF_AttributeIterator itr (myLabelNode); // Without removed attributes.
   for ( ; itr.More(); itr.Next()) {
-    if (itr.Value()->ID() == anID) {
-      anAttribute = itr.Value();
+    if (itr.PtrValue()->ID() == anID) {
+      anAttribute = itr.PtrValue();
       return Standard_True;
     }
   }
index ab01f019f9102a2277715f6e04c5fda9cf625094..e4a5be36c3f1b5c8ca42a964ce332999f319cbd2 100644 (file)
@@ -154,7 +154,7 @@ public:
   template <class T> 
   Standard_Boolean FindAttribute (const Standard_GUID& theID, Handle(T)& theAttr) const
   { 
-    Handle(TDF_Attribute) anAttr = theAttr;
+    Handle(TDF_Attribute) anAttr;
     return FindAttribute (theID, anAttr) && ! (theAttr = Handle(T)::DownCast(anAttr)).IsNull();
   }