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

Side by Side Diff: Source/wtf/Deque.h

Issue 720163002: Oilpan: Vector::reserveCapacity shouldn't reallocate backing storage always (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/wtf/DefaultAllocator.h ('k') | Source/wtf/Vector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 return; 323 return;
324 324
325 expandCapacity(); 325 expandCapacity();
326 } 326 }
327 327
328 template<typename T, size_t inlineCapacity, typename Allocator> 328 template<typename T, size_t inlineCapacity, typename Allocator>
329 void Deque<T, inlineCapacity, Allocator>::expandCapacity() 329 void Deque<T, inlineCapacity, Allocator>::expandCapacity()
330 { 330 {
331 size_t oldCapacity = m_buffer.capacity(); 331 size_t oldCapacity = m_buffer.capacity();
332 T* oldBuffer = m_buffer.buffer(); 332 T* oldBuffer = m_buffer.buffer();
333 m_buffer.allocateBuffer(std::max(static_cast<size_t>(16), oldCapacity + oldCapacity / 4 + 1)); 333 size_t newCapacity = std::max(static_cast<size_t>(16), oldCapacity + old Capacity / 4 + 1);
334 if (m_buffer.expandBuffer(newCapacity))
335 return;
336 m_buffer.allocateBuffer(newCapacity);
334 if (m_start <= m_end) 337 if (m_start <= m_end)
335 TypeOperations::move(oldBuffer + m_start, oldBuffer + m_end, m_buffe r.buffer() + m_start); 338 TypeOperations::move(oldBuffer + m_start, oldBuffer + m_end, m_buffe r.buffer() + m_start);
336 else { 339 else {
337 TypeOperations::move(oldBuffer, oldBuffer + m_end, m_buffer.buffer() ); 340 TypeOperations::move(oldBuffer, oldBuffer + m_end, m_buffer.buffer() );
338 size_t newStart = m_buffer.capacity() - (oldCapacity - m_start); 341 size_t newStart = m_buffer.capacity() - (oldCapacity - m_start);
339 TypeOperations::move(oldBuffer + m_start, oldBuffer + oldCapacity, m _buffer.buffer() + newStart); 342 TypeOperations::move(oldBuffer + m_start, oldBuffer + oldCapacity, m _buffer.buffer() + newStart);
340 m_start = newStart; 343 m_start = newStart;
341 } 344 }
342 m_buffer.deallocateBuffer(oldBuffer); 345 m_buffer.deallocateBuffer(oldBuffer);
343 } 346 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 struct NeedsTracing<Deque<T, N> > { 552 struct NeedsTracing<Deque<T, N> > {
550 static const bool value = false; 553 static const bool value = false;
551 }; 554 };
552 #endif 555 #endif
553 556
554 } // namespace WTF 557 } // namespace WTF
555 558
556 using WTF::Deque; 559 using WTF::Deque;
557 560
558 #endif // WTF_Deque_h 561 #endif // WTF_Deque_h
OLDNEW
« no previous file with comments | « Source/wtf/DefaultAllocator.h ('k') | Source/wtf/Vector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698