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.
This commit is contained in:
Pasukhin Dmitry
2025-09-11 09:36:05 +01:00
committed by GitHub
parent 1b94e22897
commit e4edfec36f
2 changed files with 7 additions and 9 deletions

View 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;

View File

@@ -22,10 +22,9 @@
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);
}