From 04068e3aea9387b710d9a129967370efe2d8d0b7 Mon Sep 17 00:00:00 2001 From: Pasukhin Dmitry Date: Sat, 14 Feb 2026 13:43:11 +0000 Subject: [PATCH] Modeling Data - Simplify EmplaceValue in Array1 and Array2 (#1087) --- .../TKernel/NCollection/NCollection_Array1.hxx | 6 ++---- .../TKernel/NCollection/NCollection_Array2.hxx | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/FoundationClasses/TKernel/NCollection/NCollection_Array1.hxx b/src/FoundationClasses/TKernel/NCollection/NCollection_Array1.hxx index 142a3a7361..c8c6746d41 100644 --- a/src/FoundationClasses/TKernel/NCollection/NCollection_Array1.hxx +++ b/src/FoundationClasses/TKernel/NCollection/NCollection_Array1.hxx @@ -334,10 +334,8 @@ public: { const size_t aPos = theIndex - myLowerBound; Standard_OutOfRange_Raise_if(aPos >= mySize, "NCollection_Array1::EmplaceValue"); - pointer aPnt = myPointer + aPos; - myAllocator.destroy(aPnt); - myAllocator.construct(aPnt, std::forward(theArgs)...); - return *aPnt; + myPointer[aPos] = value_type(std::forward(theArgs)...); + return myPointer[aPos]; } //! Changes the lowest bound. Do not move data diff --git a/src/FoundationClasses/TKernel/NCollection/NCollection_Array2.hxx b/src/FoundationClasses/TKernel/NCollection/NCollection_Array2.hxx index 92f947cbca..940913b33a 100644 --- a/src/FoundationClasses/TKernel/NCollection/NCollection_Array2.hxx +++ b/src/FoundationClasses/TKernel/NCollection/NCollection_Array2.hxx @@ -315,10 +315,8 @@ public: { const size_t aPos = (theRow - myLowerRow) * mySizeCol + (theCol - myLowerCol); Standard_OutOfRange_Raise_if(aPos >= this->mySize, "NCollection_Array2::EmplaceValue"); - pointer aPnt = this->myPointer + aPos; - this->myAllocator.destroy(aPnt); - this->myAllocator.construct(aPnt, std::forward(theArgs)...); - return *aPnt; + this->myPointer[aPos] = value_type(std::forward(theArgs)...); + return this->myPointer[aPos]; } //! Resizes the array to specified bounds.