getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] (no subject)


From: Andriy Andreykiv
Subject: [Getfem-commits] (no subject)
Date: Thu, 21 Mar 2019 10:49:57 -0400 (EDT)

branch: upgrading_getfem_to_cpp14
commit b998578ae157e4f3de01daa56b951fb417cd5923
Author: aa <address@hidden>
Date:   Thu Mar 21 15:08:15 2019 +0100

    no need for a smart pointer here. Value semantics will do.
---
 src/getfem/dal_basic.h | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/getfem/dal_basic.h b/src/getfem/dal_basic.h
index 6c59064..f3acbd5 100644
--- a/src/getfem/dal_basic.h
+++ b/src/getfem/dal_basic.h
@@ -282,7 +282,7 @@ namespace dal
 
   
   /* ********************************************************************* */
-  /* Menbers functions                                                    */
+  /* Member functions                                                      */
   /* ********************************************************************* */
 
 
@@ -324,9 +324,8 @@ namespace dal
   template<class T, unsigned char pks> 
     typename dynamic_array<T,pks>::const_reference
       dynamic_array<T,pks>::operator [](size_type ii) const { 
-        THREAD_SAFE_STATIC std::unique_ptr<T> pf = nullptr;
-        if (!pf) pf = std::make_unique<T>();
-        return (ii<last_ind) ? (array[ii>>pks])[ii&DNAMPKS__] : *pf;
+        THREAD_SAFE_STATIC T f;
+        return (ii<last_ind) ? (array[ii>>pks])[ii&DNAMPKS__] : f;
   }
 
   template<class T, unsigned char pks> typename dynamic_array<T,pks>::reference
@@ -336,13 +335,14 @@ namespace dal
       
       last_accessed = ii + 1;
       if (ii >= last_ind) {
-       if ((ii >> (pks+ppks)) > 0) {
-         while ((ii >> (pks+ppks)) > 0) ppks++; 
-         array.resize(m_ppks = (size_type(1) << ppks)); m_ppks--;
-       }
-       for (size_type jj = (last_ind >> pks); ii >= last_ind;
-            jj++, last_ind += (DNAMPKS__ + 1))
-         { array[jj] = std::unique_ptr<T[]>(new T[DNAMPKS__+1]); } // 
std::make_unique<T[]>(DNAMPKS__ + 1); }
+       if ((ii >> (pks+ppks)) > 0) {
+        while ((ii >> (pks+ppks)) > 0) ppks++; 
+        array.resize(m_ppks = (size_type(1) << ppks)); m_ppks--;
+       }
+       for (size_type jj = (last_ind >> pks); ii >= last_ind;
+            jj++, last_ind += (DNAMPKS__ + 1)){
+        array[jj] = std::unique_ptr<T[]>(new T[DNAMPKS__+1]);
+       } // std::make_unique<T[]>(DNAMPKS__ + 1); }
       }
     }
     return (array[ii >> pks])[ii & DNAMPKS__];



reply via email to

[Prev in Thread] Current Thread [Next in Thread]