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

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

Issue 2749753002: Migrate WTF::Deque::removeFirst() to ::pop_front() (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 size_t right = m_buffer.capacity() - m_start; 120 size_t right = m_buffer.capacity() - m_start;
121 return i < right ? m_buffer.buffer()[m_start + i] 121 return i < right ? m_buffer.buffer()[m_start + i]
122 : m_buffer.buffer()[i - right]; 122 : m_buffer.buffer()[i - right];
123 } 123 }
124 124
125 T& operator[](size_t i) { return at(i); } 125 T& operator[](size_t i) { return at(i); }
126 const T& operator[](size_t i) const { return at(i); } 126 const T& operator[](size_t i) const { return at(i); }
127 127
128 template <typename U> 128 template <typename U>
129 void prepend(U&&); 129 void prepend(U&&);
130 void removeFirst();
131 void remove(iterator&); 130 void remove(iterator&);
132 void remove(const_iterator&); 131 void remove(const_iterator&);
133 132
134 // STL compatibility. 133 // STL compatibility.
135 template <typename U> 134 template <typename U>
136 void push_back(U&&); 135 void push_back(U&&);
137 template <typename U> 136 template <typename U>
138 void push_front(U&& u) { 137 void push_front(U&& u) {
139 prepend(std::forward<U>(u)); 138 prepend(std::forward<U>(u));
140 } 139 }
141 void pop_back(); 140 void pop_back();
142 void pop_front() { removeFirst(); } 141 void pop_front();
143 bool empty() const { return isEmpty(); } 142 bool empty() const { return isEmpty(); }
144 T& front() { return first(); } 143 T& front() { return first(); }
145 const T& front() const { return first(); } 144 const T& front() const { return first(); }
146 T& back() { return last(); } 145 T& back() { return last(); }
147 const T& back() const { return last(); } 146 const T& back() const { return last(); }
148 template <typename... Args> 147 template <typename... Args>
149 void emplace_back(Args&&...); 148 void emplace_back(Args&&...);
150 template <typename... Args> 149 template <typename... Args>
151 void emplace_front(Args&&...); 150 void emplace_front(Args&&...);
152 151
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 m_buffer.buffer() + newStart); 478 m_buffer.buffer() + newStart);
480 m_buffer.clearUnusedSlots(oldBuffer + m_start, oldBuffer + oldCapacity); 479 m_buffer.clearUnusedSlots(oldBuffer + m_start, oldBuffer + oldCapacity);
481 m_start = newStart; 480 m_start = newStart;
482 } 481 }
483 m_buffer.deallocateBuffer(oldBuffer); 482 m_buffer.deallocateBuffer(oldBuffer);
484 } 483 }
485 484
486 template <typename T, size_t inlineCapacity, typename Allocator> 485 template <typename T, size_t inlineCapacity, typename Allocator>
487 inline T Deque<T, inlineCapacity, Allocator>::takeFirst() { 486 inline T Deque<T, inlineCapacity, Allocator>::takeFirst() {
488 T oldFirst = std::move(first()); 487 T oldFirst = std::move(first());
489 removeFirst(); 488 pop_front();
490 return oldFirst; 489 return oldFirst;
491 } 490 }
492 491
493 template <typename T, size_t inlineCapacity, typename Allocator> 492 template <typename T, size_t inlineCapacity, typename Allocator>
494 inline T Deque<T, inlineCapacity, Allocator>::takeLast() { 493 inline T Deque<T, inlineCapacity, Allocator>::takeLast() {
495 T oldLast = std::move(last()); 494 T oldLast = std::move(last());
496 pop_back(); 495 pop_back();
497 return oldLast; 496 return oldLast;
498 } 497 }
499 498
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 inline void Deque<T, inlineCapacity, Allocator>::emplace_front(Args&&... args) { 536 inline void Deque<T, inlineCapacity, Allocator>::emplace_front(Args&&... args) {
538 expandCapacityIfNeeded(); 537 expandCapacityIfNeeded();
539 if (!m_start) 538 if (!m_start)
540 m_start = m_buffer.capacity() - 1; 539 m_start = m_buffer.capacity() - 1;
541 else 540 else
542 --m_start; 541 --m_start;
543 new (NotNull, &m_buffer.buffer()[m_start]) T(std::forward<Args>(args)...); 542 new (NotNull, &m_buffer.buffer()[m_start]) T(std::forward<Args>(args)...);
544 } 543 }
545 544
546 template <typename T, size_t inlineCapacity, typename Allocator> 545 template <typename T, size_t inlineCapacity, typename Allocator>
547 inline void Deque<T, inlineCapacity, Allocator>::removeFirst() { 546 inline void Deque<T, inlineCapacity, Allocator>::pop_front() {
548 DCHECK(!isEmpty()); 547 DCHECK(!isEmpty());
549 TypeOperations::destruct(&m_buffer.buffer()[m_start], 548 TypeOperations::destruct(&m_buffer.buffer()[m_start],
550 &m_buffer.buffer()[m_start + 1]); 549 &m_buffer.buffer()[m_start + 1]);
551 m_buffer.clearUnusedSlots(&m_buffer.buffer()[m_start], 550 m_buffer.clearUnusedSlots(&m_buffer.buffer()[m_start],
552 &m_buffer.buffer()[m_start + 1]); 551 &m_buffer.buffer()[m_start + 1]);
553 if (m_start == m_buffer.capacity() - 1) 552 if (m_start == m_buffer.capacity() - 1)
554 m_start = 0; 553 m_start = 0;
555 else 554 else
556 ++m_start; 555 ++m_start;
557 } 556 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 inline void swap(Deque<T, inlineCapacity, Allocator>& a, 705 inline void swap(Deque<T, inlineCapacity, Allocator>& a,
707 Deque<T, inlineCapacity, Allocator>& b) { 706 Deque<T, inlineCapacity, Allocator>& b) {
708 a.swap(b); 707 a.swap(b);
709 } 708 }
710 709
711 } // namespace WTF 710 } // namespace WTF
712 711
713 using WTF::Deque; 712 using WTF::Deque;
714 713
715 #endif // WTF_Deque_h 714 #endif // WTF_Deque_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698