| OLD | NEW |
| 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/Partitions.h" | 10 #include "wtf/allocator/Partitions.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 if (!bufferForAlloc) { | 119 if (!bufferForAlloc) { |
| 120 size_t newBufferSize = m_buffers.isEmpty() | 120 size_t newBufferSize = m_buffers.isEmpty() |
| 121 ? kDefaultInitialBufferSize * m_maxObjectSize | 121 ? kDefaultInitialBufferSize * m_maxObjectSize |
| 122 : 2 * m_buffers.back()->capacity(); | 122 : 2 * m_buffers.back()->capacity(); |
| 123 bufferForAlloc = | 123 bufferForAlloc = |
| 124 allocateNewBufferForNextAllocation(newBufferSize, typeName); | 124 allocateNewBufferForNextAllocation(newBufferSize, typeName); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void* element = bufferForAlloc->allocate(objectSize); | 127 void* element = bufferForAlloc->allocate(objectSize); |
| 128 m_elements.append(element); | 128 m_elements.push_back(element); |
| 129 return element; | 129 return element; |
| 130 } | 130 } |
| 131 | 131 |
| 132 void ContiguousContainerBase::removeLast() { | 132 void ContiguousContainerBase::removeLast() { |
| 133 void* object = m_elements.back(); | 133 void* object = m_elements.back(); |
| 134 m_elements.pop_back(); | 134 m_elements.pop_back(); |
| 135 | 135 |
| 136 Buffer* endBuffer = m_buffers[m_endIndex].get(); | 136 Buffer* endBuffer = m_buffers[m_endIndex].get(); |
| 137 endBuffer->deallocateLastObject(object); | 137 endBuffer->deallocateLastObject(object); |
| 138 | 138 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 165 } | 165 } |
| 166 | 166 |
| 167 ContiguousContainerBase::Buffer* | 167 ContiguousContainerBase::Buffer* |
| 168 ContiguousContainerBase::allocateNewBufferForNextAllocation( | 168 ContiguousContainerBase::allocateNewBufferForNextAllocation( |
| 169 size_t bufferSize, | 169 size_t bufferSize, |
| 170 const char* typeName) { | 170 const char* typeName) { |
| 171 ASSERT(m_buffers.isEmpty() || m_endIndex == m_buffers.size() - 1); | 171 ASSERT(m_buffers.isEmpty() || m_endIndex == m_buffers.size() - 1); |
| 172 std::unique_ptr<Buffer> newBuffer = | 172 std::unique_ptr<Buffer> newBuffer = |
| 173 WTF::makeUnique<Buffer>(bufferSize, typeName); | 173 WTF::makeUnique<Buffer>(bufferSize, typeName); |
| 174 Buffer* bufferToReturn = newBuffer.get(); | 174 Buffer* bufferToReturn = newBuffer.get(); |
| 175 m_buffers.append(std::move(newBuffer)); | 175 m_buffers.push_back(std::move(newBuffer)); |
| 176 m_endIndex = m_buffers.size() - 1; | 176 m_endIndex = m_buffers.size() - 1; |
| 177 return bufferToReturn; | 177 return bufferToReturn; |
| 178 } | 178 } |
| 179 | 179 |
| 180 } // namespace blink | 180 } // namespace blink |
| OLD | NEW |