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

Unified Diff: Source/wtf/Deque.h

Issue 835453002: Add missing buffer reorg on Deque buffer expansion. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Scale back added comments in Deque.h Created 5 years, 12 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/platform/heap/HeapTest.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 b0ab0c4260a20d6ab0759419908300b08f628d54..0031c549cc04e3f478240663d046b00313fa9ab5 100644
--- a/Source/wtf/Deque.h
+++ b/Source/wtf/Deque.h
@@ -331,8 +331,16 @@ namespace WTF {
size_t oldCapacity = m_buffer.capacity();
T* oldBuffer = m_buffer.buffer();
size_t newCapacity = std::max(static_cast<size_t>(16), oldCapacity + oldCapacity / 4 + 1);
- if (m_buffer.expandBuffer(newCapacity))
+ if (m_buffer.expandBuffer(newCapacity)) {
+ if (m_start <= m_end) {
+ // No adjustments to be done.
+ } else {
+ size_t newStart = m_buffer.capacity() - (oldCapacity - m_start);
+ TypeOperations::moveOverlapping(oldBuffer + m_start, oldBuffer + oldCapacity, m_buffer.buffer() + newStart);
+ m_start = newStart;
+ }
return;
+ }
m_buffer.allocateBuffer(newCapacity);
if (m_start <= m_end)
TypeOperations::move(oldBuffer + m_start, oldBuffer + m_end, m_buffer.buffer() + m_start);
« no previous file with comments | « Source/platform/heap/HeapTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698