aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkTLList.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkTLList.h')
-rw-r--r--src/core/SkTLList.h22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/core/SkTLList.h b/src/core/SkTLList.h
index b865538c27..8680ea2e45 100644
--- a/src/core/SkTLList.h
+++ b/src/core/SkTLList.h
@@ -8,9 +8,9 @@
#ifndef SkTLList_DEFINED
#define SkTLList_DEFINED
-#include "SkTInternalLList.h"
-
#include "SkMalloc.h"
+#include "SkTInternalLList.h"
+#include "SkTemplates.h"
#include "SkTypes.h"
#include <new>
#include <utility>
@@ -32,7 +32,7 @@ template <typename T, unsigned int N> class SkTLList : SkNoncopyable {
private:
struct Block;
struct Node {
- char fObj[sizeof(T)];
+ SkAlignedSTStorage<1, T> fObj;
SK_DECLARE_INTERNAL_LLIST_INTERFACE(Node);
Block* fBlock; // owning block.
};
@@ -51,7 +51,7 @@ public:
typename NodeList::Iter iter;
Node* node = iter.init(fList, Iter::kHead_IterStart);
while (node) {
- SkTCast<T*>(node->fObj)->~T();
+ reinterpret_cast<T*>(node->fObj.get())->~T();
Block* block = node->fBlock;
node = iter.next();
if (0 == --block->fNodesInUse) {
@@ -71,7 +71,7 @@ public:
Node* node = this->createNode();
fList.addToHead(node);
this->validate();
- return new (node->fObj) T(std::forward<Args>(args)...);
+ return new (node->fObj.get()) T(std::forward<Args>(args)...);
}
/** Adds a new element to the list at the tail. */
@@ -80,7 +80,7 @@ public:
Node* node = this->createNode();
fList.addToTail(node);
this->validate();
- return new (node->fObj) T(std::forward<Args>(args)...);
+ return new (node->fObj.get()) T(std::forward<Args>(args)...);
}
/** Adds a new element to the list before the location indicated by the iterator. If the
@@ -90,7 +90,7 @@ public:
Node* node = this->createNode();
fList.addBefore(node, location.getNode());
this->validate();
- return new (node->fObj) T(std::forward<Args>(args)...);
+ return new (node->fObj.get()) T(std::forward<Args>(args)...);
}
/** Adds a new element to the list after the location indicated by the iterator. If the
@@ -100,7 +100,7 @@ public:
Node* node = this->createNode();
fList.addAfter(node, location.getNode());
this->validate();
- return new (node->fObj) T(std::forward<Args>(args)...);
+ return new (node->fObj.get()) T(std::forward<Args>(args)...);
}
/** Convenience methods for getting an iterator initialized to the head/tail of the list. */
@@ -133,7 +133,7 @@ public:
void remove(T* t) {
this->validate();
Node* node = reinterpret_cast<Node*>(t);
- SkASSERT(reinterpret_cast<T*>(node->fObj) == t);
+ SkASSERT(reinterpret_cast<T*>(node->fObj.get()) == t);
this->removeNode(node);
this->validate();
}
@@ -210,7 +210,7 @@ public:
T* nodeToObj(Node* node) {
if (node) {
- return reinterpret_cast<T*>(node->fObj);
+ return reinterpret_cast<T*>(node->fObj.get());
} else {
return nullptr;
}
@@ -264,7 +264,7 @@ private:
void removeNode(Node* node) {
SkASSERT(node);
fList.remove(node);
- SkTCast<T*>(node->fObj)->~T();
+ reinterpret_cast<T*>(node->fObj.get())->~T();
Block* block = node->fBlock;
// Don't ever elease the first block, just add its nodes to the free list
if (0 == --block->fNodesInUse && block != &fFirstBlock) {