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

Unified Diff: Source/wtf/Deque.h

Issue 24980002: Implement AP2 Promises (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 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 | « Source/bindings/v8/custom/V8PromiseCustom.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/Deque.h
diff --git a/Source/wtf/Deque.h b/Source/wtf/Deque.h
index 3ce433729a4c86cfc3bd040a3c665cefc1e8ded8..fa6c8945b847eb024e7edd0fa57feeb28a4b2699 100644
--- a/Source/wtf/Deque.h
+++ b/Source/wtf/Deque.h
@@ -79,10 +79,12 @@ namespace WTF {
T& last() { ASSERT(m_start != m_end); return *(--end()); }
const T& last() const { ASSERT(m_start != m_end); return *(--end()); }
+ PassType takeLast();
template<typename U> void append(const U&);
template<typename U> void prepend(const U&);
void removeFirst();
+ void removeLast();
void remove(iterator&);
void remove(const_iterator&);
@@ -326,6 +328,14 @@ namespace WTF {
return Pass::transfer(oldFirst);
}
+ template<typename T, size_t inlineCapacity>
+ inline typename Deque<T, inlineCapacity>::PassType Deque<T, inlineCapacity>::takeLast()
+ {
+ T oldLast = Pass::transfer(last());
+ removeLast();
+ return Pass::transfer(oldLast);
+ }
+
template<typename T, size_t inlineCapacity> template<typename U>
inline void Deque<T, inlineCapacity>::append(const U& value)
{
@@ -360,6 +370,17 @@ namespace WTF {
}
template<typename T, size_t inlineCapacity>
+ inline void Deque<T, inlineCapacity>::removeLast()
+ {
+ ASSERT(!isEmpty());
+ if (!m_end)
+ m_end = m_buffer.capacity() - 1;
+ else
+ --m_end;
+ TypeOperations::destruct(&m_buffer.buffer()[m_end], &m_buffer.buffer()[m_end + 1]);
+ }
+
+ template<typename T, size_t inlineCapacity>
inline void Deque<T, inlineCapacity>::remove(iterator& it)
{
remove(it.m_index);
« no previous file with comments | « Source/bindings/v8/custom/V8PromiseCustom.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698