summaryrefslogtreecommitdiffstats
path: root/Source/WTF/wtf/Deque.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-09-13 12:51:20 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-19 20:50:05 +0200
commitd441d6f39bb846989d95bcf5caf387b42414718d (patch)
treee367e64a75991c554930278175d403c072de6bb8 /Source/WTF/wtf/Deque.h
parent0060b2994c07842f4c59de64b5e3e430525c4b90 (diff)
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit. Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/WTF/wtf/Deque.h')
-rw-r--r--Source/WTF/wtf/Deque.h30
1 files changed, 27 insertions, 3 deletions
diff --git a/Source/WTF/wtf/Deque.h b/Source/WTF/wtf/Deque.h
index e5c47b63e..5350c7ac9 100644
--- a/Source/WTF/wtf/Deque.h
+++ b/Source/WTF/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&);
@@ -348,6 +350,7 @@ namespace WTF {
destroyAll();
m_start = 0;
m_end = 0;
+ m_buffer.deallocateBuffer(m_buffer.buffer());
checkValidity();
}
@@ -383,14 +386,13 @@ namespace WTF {
{
checkValidity();
size_t oldCapacity = m_buffer.capacity();
- size_t newCapacity = std::max(static_cast<size_t>(16), oldCapacity + oldCapacity / 4 + 1);
T* oldBuffer = m_buffer.buffer();
- m_buffer.allocateBuffer(newCapacity);
+ m_buffer.allocateBuffer(std::max(static_cast<size_t>(16), oldCapacity + oldCapacity / 4 + 1));
if (m_start <= m_end)
TypeOperations::move(oldBuffer + m_start, oldBuffer + m_end, m_buffer.buffer() + m_start);
else {
TypeOperations::move(oldBuffer, oldBuffer + m_end, m_buffer.buffer());
- size_t newStart = newCapacity - (oldCapacity - m_start);
+ size_t newStart = m_buffer.capacity() - (oldCapacity - m_start);
TypeOperations::move(oldBuffer + m_start, oldBuffer + oldCapacity, m_buffer.buffer() + newStart);
m_start = newStart;
}
@@ -406,6 +408,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)
{
@@ -447,6 +457,20 @@ namespace WTF {
}
template<typename T, size_t inlineCapacity>
+ inline void Deque<T, inlineCapacity>::removeLast()
+ {
+ checkValidity();
+ invalidateIterators();
+ 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]);
+ checkValidity();
+ }
+
+ template<typename T, size_t inlineCapacity>
inline void Deque<T, inlineCapacity>::remove(iterator& it)
{
it.checkValidity();