Bug 1251718 - use UniquePtr instead of ScopedDeletePtr in WebGLElementArrayCache; r=baku
authorNathan Froyd <froydnj@mozilla.com>
Fri, 26 Feb 2016 13:29:19 -0500
changeset 322437 cf5d8cf6d7d81d2c155638cb52482391a74c9efc
parent 322436 0a02f7974084fb93344dab6f2d00d1e8edd55cf6
child 322438 b26f4f428a14f2375834297943a371c24af362a6
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)
reviewersbaku
bugs1251718
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 1251718 - use UniquePtr instead of ScopedDeletePtr in WebGLElementArrayCache; r=baku UniquePtr is more standard than ScopedDeletePtr; using standard constructs whenever possible is preferable.
dom/canvas/WebGLElementArrayCache.cpp
dom/canvas/WebGLElementArrayCache.h
--- a/dom/canvas/WebGLElementArrayCache.cpp
+++ b/dom/canvas/WebGLElementArrayCache.cpp
@@ -319,35 +319,35 @@ public:
 // TreeForType: just a template helper to select the right tree object for a given
 // element type.
 template<typename T>
 struct TreeForType {};
 
 template<>
 struct TreeForType<uint8_t>
 {
-    static ScopedDeletePtr<WebGLElementArrayCacheTree<uint8_t>>&
+    static UniquePtr<WebGLElementArrayCacheTree<uint8_t>>&
     Value(WebGLElementArrayCache* b) {
         return b->mUint8Tree;
     }
 };
 
 template<>
 struct TreeForType<uint16_t>
 {
-    static ScopedDeletePtr<WebGLElementArrayCacheTree<uint16_t>>&
+    static UniquePtr<WebGLElementArrayCacheTree<uint16_t>>&
     Value(WebGLElementArrayCache* b) {
         return b->mUint16Tree;
     }
 };
 
 template<>
 struct TreeForType<uint32_t>
 {
-    static ScopedDeletePtr<WebGLElementArrayCacheTree<uint32_t>>&
+    static UniquePtr<WebGLElementArrayCacheTree<uint32_t>>&
     Value(WebGLElementArrayCache* b) {
         return b->mUint32Tree;
     }
 };
 
 // Calling this method will 1) update the leaves in this interval
 // from the raw buffer data, and 2) propagate this update up the tree.
 template<typename T>
@@ -531,19 +531,19 @@ WebGLElementArrayCache::Validate(uint32_
 
     // Integer overflow must have been handled earlier, so we assert that
     // maxAllowedT is exactly the max allowed value.
     MOZ_ASSERT(uint32_t(maxAllowedT) == maxAllowed);
 
     if (!mBytes.Length() || !countElements)
       return true;
 
-    ScopedDeletePtr<WebGLElementArrayCacheTree<T>>& tree = TreeForType<T>::Value(this);
+    UniquePtr<WebGLElementArrayCacheTree<T>>& tree = TreeForType<T>::Value(this);
     if (!tree) {
-        tree = new WebGLElementArrayCacheTree<T>(*this);
+        tree = MakeUnique<WebGLElementArrayCacheTree<T>>(*this);
         if (mBytes.Length()) {
             bool valid = tree->Update(0, mBytes.Length() - 1);
             if (!valid) {
                 // Do not assert here. This case would happen if an allocation
                 // failed. We've already settled on fallible allocations around
                 // here.
                 tree = nullptr;
                 return false;
--- a/dom/canvas/WebGLElementArrayCache.h
+++ b/dom/canvas/WebGLElementArrayCache.h
@@ -3,17 +3,17 @@
  * 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 WEBGL_ELEMENT_ARRAY_CACHE_H
 #define WEBGL_ELEMENT_ARRAY_CACHE_H
 
 #include "GLDefs.h"
 #include "mozilla/MemoryReporting.h"
-#include "mozilla/Scoped.h"
+#include "mozilla/UniquePtr.h"
 #include "nscore.h"
 #include "nsTArray.h"
 #include <stdint.h>
 
 namespace mozilla {
 
 template<typename T>
 struct WebGLElementArrayCacheTree;
@@ -88,16 +88,16 @@ private:
     bool UpdateTrees(size_t firstByte, size_t lastByte);
 
     template<typename T>
     friend struct WebGLElementArrayCacheTree;
     template<typename T>
     friend struct TreeForType;
 
     FallibleTArray<uint8_t> mBytes;
-    ScopedDeletePtr<WebGLElementArrayCacheTree<uint8_t>> mUint8Tree;
-    ScopedDeletePtr<WebGLElementArrayCacheTree<uint16_t>> mUint16Tree;
-    ScopedDeletePtr<WebGLElementArrayCacheTree<uint32_t>> mUint32Tree;
+    UniquePtr<WebGLElementArrayCacheTree<uint8_t>> mUint8Tree;
+    UniquePtr<WebGLElementArrayCacheTree<uint16_t>> mUint16Tree;
+    UniquePtr<WebGLElementArrayCacheTree<uint32_t>> mUint32Tree;
 };
 
 } // end namespace mozilla
 
 #endif // WEBGL_ELEMENT_ARRAY_CACHE_H