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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ContiguousContainer.cpp

Issue 2459003003: WTF/std normalization: replace WTF::Vector::removeLast with ::pop_back (Closed)
Patch Set: rebase Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/graphics/ContiguousContainer.h" 5 #include "platform/graphics/ContiguousContainer.h"
6 6
7 #include "wtf/Allocator.h" 7 #include "wtf/Allocator.h"
8 #include "wtf/ContainerAnnotations.h" 8 #include "wtf/ContainerAnnotations.h"
9 #include "wtf/PtrUtil.h" 9 #include "wtf/PtrUtil.h"
10 #include "wtf/allocator/PartitionAlloc.h" 10 #include "wtf/allocator/PartitionAlloc.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 allocateNewBufferForNextAllocation(newBufferSize, typeName); 125 allocateNewBufferForNextAllocation(newBufferSize, typeName);
126 } 126 }
127 127
128 void* element = bufferForAlloc->allocate(objectSize); 128 void* element = bufferForAlloc->allocate(objectSize);
129 m_elements.append(element); 129 m_elements.append(element);
130 return element; 130 return element;
131 } 131 }
132 132
133 void ContiguousContainerBase::removeLast() { 133 void ContiguousContainerBase::removeLast() {
134 void* object = m_elements.last(); 134 void* object = m_elements.last();
135 m_elements.removeLast(); 135 m_elements.pop_back();
136 136
137 Buffer* endBuffer = m_buffers[m_endIndex].get(); 137 Buffer* endBuffer = m_buffers[m_endIndex].get();
138 endBuffer->deallocateLastObject(object); 138 endBuffer->deallocateLastObject(object);
139 139
140 if (endBuffer->isEmpty()) { 140 if (endBuffer->isEmpty()) {
141 if (m_endIndex > 0) 141 if (m_endIndex > 0)
142 m_endIndex--; 142 m_endIndex--;
143 if (m_endIndex + 2 < m_buffers.size()) 143 if (m_endIndex + 2 < m_buffers.size())
144 m_buffers.removeLast(); 144 m_buffers.pop_back();
145 } 145 }
146 } 146 }
147 147
148 void ContiguousContainerBase::clear() { 148 void ContiguousContainerBase::clear() {
149 m_elements.clear(); 149 m_elements.clear();
150 m_buffers.clear(); 150 m_buffers.clear();
151 m_endIndex = 0; 151 m_endIndex = 0;
152 } 152 }
153 153
154 void ContiguousContainerBase::swap(ContiguousContainerBase& other) { 154 void ContiguousContainerBase::swap(ContiguousContainerBase& other) {
155 m_elements.swap(other.m_elements); 155 m_elements.swap(other.m_elements);
156 m_buffers.swap(other.m_buffers); 156 m_buffers.swap(other.m_buffers);
157 std::swap(m_endIndex, other.m_endIndex); 157 std::swap(m_endIndex, other.m_endIndex);
158 std::swap(m_maxObjectSize, other.m_maxObjectSize); 158 std::swap(m_maxObjectSize, other.m_maxObjectSize);
159 } 159 }
160 160
161 void ContiguousContainerBase::shrinkToFit() { 161 void ContiguousContainerBase::shrinkToFit() {
162 while (m_endIndex < m_buffers.size() - 1) { 162 while (m_endIndex < m_buffers.size() - 1) {
163 DCHECK(m_buffers.last()->isEmpty()); 163 DCHECK(m_buffers.last()->isEmpty());
164 m_buffers.removeLast(); 164 m_buffers.pop_back();
165 } 165 }
166 } 166 }
167 167
168 ContiguousContainerBase::Buffer* 168 ContiguousContainerBase::Buffer*
169 ContiguousContainerBase::allocateNewBufferForNextAllocation( 169 ContiguousContainerBase::allocateNewBufferForNextAllocation(
170 size_t bufferSize, 170 size_t bufferSize,
171 const char* typeName) { 171 const char* typeName) {
172 ASSERT(m_buffers.isEmpty() || m_endIndex == m_buffers.size() - 1); 172 ASSERT(m_buffers.isEmpty() || m_endIndex == m_buffers.size() - 1);
173 std::unique_ptr<Buffer> newBuffer = 173 std::unique_ptr<Buffer> newBuffer =
174 wrapUnique(new Buffer(bufferSize, typeName)); 174 wrapUnique(new Buffer(bufferSize, typeName));
175 Buffer* bufferToReturn = newBuffer.get(); 175 Buffer* bufferToReturn = newBuffer.get();
176 m_buffers.append(std::move(newBuffer)); 176 m_buffers.append(std::move(newBuffer));
177 m_endIndex = m_buffers.size() - 1; 177 m_endIndex = m_buffers.size() - 1;
178 return bufferToReturn; 178 return bufferToReturn;
179 } 179 }
180 180
181 } // namespace blink 181 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698