From e4edfec36fd96b7d931341eca0ef8b7185747cd5 Mon Sep 17 00:00:00 2001 From: Pasukhin Dmitry Date: Thu, 11 Sep 2025 09:36:05 +0100 Subject: [PATCH] Foundation Classes - math Container optimization (#717) 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. --- .../TKMath/math/math_DoubleTab.hxx | 2 +- .../TKMath/math/math_VectorBase.lxx | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/FoundationClasses/TKMath/math/math_DoubleTab.hxx b/src/FoundationClasses/TKMath/math/math_DoubleTab.hxx index be337d45de..66ff0e6c7a 100644 --- a/src/FoundationClasses/TKMath/math/math_DoubleTab.hxx +++ b/src/FoundationClasses/TKMath/math/math_DoubleTab.hxx @@ -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; diff --git a/src/FoundationClasses/TKMath/math/math_VectorBase.lxx b/src/FoundationClasses/TKMath/math/math_VectorBase.lxx index ef4cf770c5..1b06c37127 100644 --- a/src/FoundationClasses/TKMath/math/math_VectorBase.lxx +++ b/src/FoundationClasses/TKMath/math/math_VectorBase.lxx @@ -22,10 +22,9 @@ template math_VectorBase::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(*myBuffer.data(), theLower, theUpper) + : NCollection_Array1(theLower, theUpper)) { } @@ -33,10 +32,9 @@ template math_VectorBase::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(*myBuffer.data(), theLower, theUpper) + : NCollection_Array1(theLower, theUpper)) { Array.Init(theInitialValue); } -- 2.39.5