Bug 1252153 - use UniquePtr instead of ScopedDeletePtr in HeapCopyOfStackArray; r=jrmuizel
authorNathan Froyd <froydnj@mozilla.com>
Mon, 29 Feb 2016 11:54:36 -0500
changeset 322482 c740c50ee694083a430e98faa37f864b5a539f24
parent 322481 90cef80ab3099df78dca2d48f55fb6bd23db7eaf
child 322483 95703fdc2175444a69dfb154f7d1bad74f19cf79
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1252153
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1252153 - use UniquePtr instead of ScopedDeletePtr in HeapCopyOfStackArray; r=jrmuizel UniquePtr is more standard than ScopedDeletePtr; using standard constructs whenever possible is preferable.
gfx/gl/HeapCopyOfStackArray.h
--- a/gfx/gl/HeapCopyOfStackArray.h
+++ b/gfx/gl/HeapCopyOfStackArray.h
@@ -1,47 +1,47 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=4 et sw=4 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef HEAPCOPYOFSTACKARRAY_H_
 #define HEAPCOPYOFSTACKARRAY_H_
 
 #include "mozilla/Attributes.h"
-#include "mozilla/Scoped.h"
+#include "mozilla/UniquePtr.h"
 
 #include <string.h>
 
 namespace mozilla {
 
 // Takes a stack array and copies it into a heap buffer.
 // Useful to retain the convenience of declaring static arrays, while
 // avoiding passing stack pointers to the GL (see bug 1005658).
 
 template <typename ElemType>
 class HeapCopyOfStackArray
 {
 public:
   template<size_t N>
   MOZ_IMPLICIT HeapCopyOfStackArray(ElemType (&array)[N])
     : mArrayLength(N)
-    , mArrayData(new ElemType[N])
+    , mArrayData(MakeUnique<ElemType[]>(N))
   {
-    memcpy(mArrayData, &array[0], N * sizeof(ElemType));
+    memcpy(mArrayData.get(), &array[0], N * sizeof(ElemType));
   }
 
-  ElemType* Data() const { return mArrayData; }
+  ElemType* Data() const { return mArrayData.get(); }
   size_t ArrayLength() const { return mArrayLength; }
   size_t ByteLength() const { return mArrayLength * sizeof(ElemType); }
 
 private:
   HeapCopyOfStackArray() = delete;
   HeapCopyOfStackArray(const HeapCopyOfStackArray&) = delete;
 
   const size_t mArrayLength;
-  ScopedDeletePtr<ElemType> const mArrayData;
+  UniquePtr<ElemType[]> const mArrayData;
 };
 
 } // namespace mozilla
 
 #endif // HEAPCOPYOFSTACKARRAY_H_