Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: third_party/WebKit/Source/wtf/Deque.h

Issue 1846473002: WTF: Implement move of Deques. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/DequeTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/Deque.h
diff --git a/third_party/WebKit/Source/wtf/Deque.h b/third_party/WebKit/Source/wtf/Deque.h
index 19a19fa14394ed6e2fd6602216a08ba19e7eef80..852fdd38a914dd53a4f341be894593540a5a9fa6 100644
--- a/third_party/WebKit/Source/wtf/Deque.h
+++ b/third_party/WebKit/Source/wtf/Deque.h
@@ -52,13 +52,15 @@ public:
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
Deque();
- Deque(const Deque<T, inlineCapacity, Allocator>&);
+ Deque(const Deque&);
Deque& operator=(const Deque&);
+ Deque(Deque&&);
+ Deque& operator=(Deque&&);
void finalize();
void finalizeGarbageCollectedObject() { finalize(); }
- void swap(Deque<T, inlineCapacity, Allocator>&);
+ void swap(Deque&);
size_t size() const { return m_start <= m_end ? m_end - m_start : m_end + m_buffer.capacity() - m_start; }
bool isEmpty() const { return m_start == m_end; }
@@ -110,6 +112,12 @@ public:
template <typename VisitorDispatcher> void trace(VisitorDispatcher);
+ static_assert(!std::is_polymorphic<T>::value || !VectorTraits<T>::canInitializeWithMemset, "Cannot initialize with memset if there is a vtable");
+#if ENABLE(OILPAN)
+ static_assert(Allocator::isGarbageCollected || !AllowsOnlyPlacementNew<T>::value || !NeedsTracing<T>::value, "Cannot put DISALLOW_NEW_EXCEPT_PLACEMENT_NEW objects that have trace methods into an off-heap Deque");
+#endif
+ static_assert(Allocator::isGarbageCollected || !IsPointerToGarbageCollectedType<T>::value, "Cannot put raw pointers to garbage-collected classes into a Deque. Use HeapDeque<Member<T>> instead.");
+
private:
friend class DequeIteratorBase<T, inlineCapacity, Allocator>;
@@ -237,15 +245,10 @@ inline Deque<T, inlineCapacity, Allocator>::Deque()
: m_start(0)
, m_end(0)
{
- static_assert(!std::is_polymorphic<T>::value || !VectorTraits<T>::canInitializeWithMemset, "Cannot initialize with memset if there is a vtable");
-#if ENABLE(OILPAN)
- static_assert(Allocator::isGarbageCollected || !AllowsOnlyPlacementNew<T>::value || !NeedsTracing<T>::value, "Cannot put DISALLOW_NEW_EXCEPT_PLACEMENT_NEW objects that have trace methods into an off-heap Deque");
-#endif
- static_assert(Allocator::isGarbageCollected || !IsPointerToGarbageCollectedType<T>::value, "Cannot put raw pointers to garbage-collected classes into a Deque. Use HeapDeque<Member<T>> instead.");
}
template <typename T, size_t inlineCapacity, typename Allocator>
-inline Deque<T, inlineCapacity, Allocator>::Deque(const Deque<T, inlineCapacity, Allocator>& other)
+inline Deque<T, inlineCapacity, Allocator>::Deque(const Deque& other)
: m_buffer(other.m_buffer.capacity())
, m_start(other.m_start)
, m_end(other.m_end)
@@ -268,6 +271,21 @@ inline Deque<T, inlineCapacity, Allocator>& Deque<T, inlineCapacity, Allocator>:
}
template <typename T, size_t inlineCapacity, typename Allocator>
+inline Deque<T, inlineCapacity, Allocator>::Deque(Deque&& other)
+ : m_start(0)
+ , m_end(0)
+{
+ swap(other);
+}
+
+template <typename T, size_t inlineCapacity, typename Allocator>
+inline Deque<T, inlineCapacity, Allocator>& Deque<T, inlineCapacity, Allocator>::operator=(Deque&& other)
+{
+ swap(other);
+ return *this;
+}
+
+template <typename T, size_t inlineCapacity, typename Allocator>
inline void Deque<T, inlineCapacity, Allocator>::destroyAll()
{
if (m_start <= m_end) {
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/DequeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698