| OLD | NEW |
| 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 size_t newCapacity = std::max(static_cast<size_t>(16), oldCapacity + old
Capacity / 4 + 1); | 333 size_t newCapacity = std::max(static_cast<size_t>(16), oldCapacity + old
Capacity / 4 + 1); |
| 334 if (m_buffer.expandBuffer(newCapacity)) | 334 if (m_buffer.expandBuffer(newCapacity)) { |
| 335 if (m_start <= m_end) { |
| 336 // No adjustments to be done. |
| 337 } else { |
| 338 size_t newStart = m_buffer.capacity() - (oldCapacity - m_start); |
| 339 TypeOperations::moveOverlapping(oldBuffer + m_start, oldBuffer +
oldCapacity, m_buffer.buffer() + newStart); |
| 340 m_start = newStart; |
| 341 } |
| 335 return; | 342 return; |
| 343 } |
| 336 m_buffer.allocateBuffer(newCapacity); | 344 m_buffer.allocateBuffer(newCapacity); |
| 337 if (m_start <= m_end) | 345 if (m_start <= m_end) |
| 338 TypeOperations::move(oldBuffer + m_start, oldBuffer + m_end, m_buffe
r.buffer() + m_start); | 346 TypeOperations::move(oldBuffer + m_start, oldBuffer + m_end, m_buffe
r.buffer() + m_start); |
| 339 else { | 347 else { |
| 340 TypeOperations::move(oldBuffer, oldBuffer + m_end, m_buffer.buffer()
); | 348 TypeOperations::move(oldBuffer, oldBuffer + m_end, m_buffer.buffer()
); |
| 341 size_t newStart = m_buffer.capacity() - (oldCapacity - m_start); | 349 size_t newStart = m_buffer.capacity() - (oldCapacity - m_start); |
| 342 TypeOperations::move(oldBuffer + m_start, oldBuffer + oldCapacity, m
_buffer.buffer() + newStart); | 350 TypeOperations::move(oldBuffer + m_start, oldBuffer + oldCapacity, m
_buffer.buffer() + newStart); |
| 343 m_start = newStart; | 351 m_start = newStart; |
| 344 } | 352 } |
| 345 m_buffer.deallocateBuffer(oldBuffer); | 353 m_buffer.deallocateBuffer(oldBuffer); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 struct NeedsTracing<Deque<T, N> > { | 560 struct NeedsTracing<Deque<T, N> > { |
| 553 static const bool value = false; | 561 static const bool value = false; |
| 554 }; | 562 }; |
| 555 #endif | 563 #endif |
| 556 | 564 |
| 557 } // namespace WTF | 565 } // namespace WTF |
| 558 | 566 |
| 559 using WTF::Deque; | 567 using WTF::Deque; |
| 560 | 568 |
| 561 #endif // WTF_Deque_h | 569 #endif // WTF_Deque_h |
| OLD | NEW |