Bug 1251718 - use UniquePtr instead of ScopedDeletePtr in WebGLElementArrayCache; r=baku

UniquePtr is more standard than ScopedDeletePtr; using standard
constructs whenever possible is preferable.
This commit is contained in:
Nathan Froyd 2016-02-26 13:29:19 -05:00
Родитель 465a32ca37
Коммит 97bd5781a5
2 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@ -324,7 +324,7 @@ struct TreeForType {};
template<> template<>
struct TreeForType<uint8_t> struct TreeForType<uint8_t>
{ {
static ScopedDeletePtr<WebGLElementArrayCacheTree<uint8_t>>& static UniquePtr<WebGLElementArrayCacheTree<uint8_t>>&
Value(WebGLElementArrayCache* b) { Value(WebGLElementArrayCache* b) {
return b->mUint8Tree; return b->mUint8Tree;
} }
@ -333,7 +333,7 @@ struct TreeForType<uint8_t>
template<> template<>
struct TreeForType<uint16_t> struct TreeForType<uint16_t>
{ {
static ScopedDeletePtr<WebGLElementArrayCacheTree<uint16_t>>& static UniquePtr<WebGLElementArrayCacheTree<uint16_t>>&
Value(WebGLElementArrayCache* b) { Value(WebGLElementArrayCache* b) {
return b->mUint16Tree; return b->mUint16Tree;
} }
@ -342,7 +342,7 @@ struct TreeForType<uint16_t>
template<> template<>
struct TreeForType<uint32_t> struct TreeForType<uint32_t>
{ {
static ScopedDeletePtr<WebGLElementArrayCacheTree<uint32_t>>& static UniquePtr<WebGLElementArrayCacheTree<uint32_t>>&
Value(WebGLElementArrayCache* b) { Value(WebGLElementArrayCache* b) {
return b->mUint32Tree; return b->mUint32Tree;
} }
@ -536,9 +536,9 @@ WebGLElementArrayCache::Validate(uint32_t maxAllowed, size_t firstElement,
if (!mBytes.Length() || !countElements) if (!mBytes.Length() || !countElements)
return true; return true;
ScopedDeletePtr<WebGLElementArrayCacheTree<T>>& tree = TreeForType<T>::Value(this); UniquePtr<WebGLElementArrayCacheTree<T>>& tree = TreeForType<T>::Value(this);
if (!tree) { if (!tree) {
tree = new WebGLElementArrayCacheTree<T>(*this); tree = MakeUnique<WebGLElementArrayCacheTree<T>>(*this);
if (mBytes.Length()) { if (mBytes.Length()) {
bool valid = tree->Update(0, mBytes.Length() - 1); bool valid = tree->Update(0, mBytes.Length() - 1);
if (!valid) { if (!valid) {

Просмотреть файл

@ -8,7 +8,7 @@
#include "GLDefs.h" #include "GLDefs.h"
#include "mozilla/MemoryReporting.h" #include "mozilla/MemoryReporting.h"
#include "mozilla/Scoped.h" #include "mozilla/UniquePtr.h"
#include "nscore.h" #include "nscore.h"
#include "nsTArray.h" #include "nsTArray.h"
#include <stdint.h> #include <stdint.h>
@ -93,9 +93,9 @@ private:
friend struct TreeForType; friend struct TreeForType;
FallibleTArray<uint8_t> mBytes; FallibleTArray<uint8_t> mBytes;
ScopedDeletePtr<WebGLElementArrayCacheTree<uint8_t>> mUint8Tree; UniquePtr<WebGLElementArrayCacheTree<uint8_t>> mUint8Tree;
ScopedDeletePtr<WebGLElementArrayCacheTree<uint16_t>> mUint16Tree; UniquePtr<WebGLElementArrayCacheTree<uint16_t>> mUint16Tree;
ScopedDeletePtr<WebGLElementArrayCacheTree<uint32_t>> mUint32Tree; UniquePtr<WebGLElementArrayCacheTree<uint32_t>> mUint32Tree;
}; };
} // end namespace mozilla } // end namespace mozilla