]> OCCT Git - occt.git/commitdiff
Foundation Classes - math Container optimization (#717) master
authorPasukhin Dmitry <dpasukhi@opencascade.com>
Thu, 11 Sep 2025 08:36:05 +0000 (09:36 +0100)
committerGitHub <noreply@github.com>
Thu, 11 Sep 2025 08:36:05 +0000 (09:36 +0100)
Increase DoubleTab container buffer size to 64 from 16.
Optimize the vector initialisation with 5-10% increasing time.
  Before the creating was takes too much branching.

src/FoundationClasses/TKMath/math/math_DoubleTab.hxx
src/FoundationClasses/TKMath/math/math_VectorBase.lxx

index be337d45dee5914e205a10437797ba7406fc102c..66ff0e6c7af77f9c8d4625341b1e11869e1b6117 100644 (file)
@@ -29,7 +29,7 @@
 
 class math_DoubleTab
 {
-  static const Standard_Integer THE_BUFFER_SIZE = 16;
+  static const Standard_Integer THE_BUFFER_SIZE = 64;
 
 public:
   DEFINE_STANDARD_ALLOC;
index ef4cf770c5e6f259a40bf2c4173949fe9e7aee2d..1b06c3712782a0d9e1b9d9b688527e1d776912ee 100644 (file)
 template <typename TheItemType>
 math_VectorBase<TheItemType>::math_VectorBase(const Standard_Integer theLower,
                                               const Standard_Integer theUpper)
-    : Array(*myBuffer.data(),
-            theLower,
-            theUpper,
-            (theUpper - theLower + 1 <= math_VectorBase::THE_BUFFER_SIZE))
+    : Array(theUpper - theLower + 1 <= math_VectorBase::THE_BUFFER_SIZE
+              ? NCollection_Array1<TheItemType>(*myBuffer.data(), theLower, theUpper)
+              : NCollection_Array1<TheItemType>(theLower, theUpper))
 {
 }
 
@@ -33,10 +32,9 @@ template <typename TheItemType>
 math_VectorBase<TheItemType>::math_VectorBase(const Standard_Integer theLower,
                                               const Standard_Integer theUpper,
                                               const TheItemType      theInitialValue)
-    : Array(*myBuffer.data(),
-            theLower,
-            theUpper,
-            (theUpper - theLower + 1 <= math_VectorBase::THE_BUFFER_SIZE))
+    : Array(theUpper - theLower + 1 <= math_VectorBase::THE_BUFFER_SIZE
+              ? NCollection_Array1<TheItemType>(*myBuffer.data(), theLower, theUpper)
+              : NCollection_Array1<TheItemType>(theLower, theUpper))
 {
   Array.Init(theInitialValue);
 }