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

Side by Side Diff: third_party/WebKit/Source/platform/PODArena.h

Issue 2615813003: Migrate WTF::Vector::append() to ::push_back() [part 14 of N] (Closed)
Patch Set: rebase, small fix in FontSettings.h Created 3 years, 11 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 template <class T> 122 template <class T>
123 void* allocateBase() { 123 void* allocateBase() {
124 void* ptr = 0; 124 void* ptr = 0;
125 size_t roundedSize = roundUp(sizeof(T), minAlignment<T>()); 125 size_t roundedSize = roundUp(sizeof(T), minAlignment<T>());
126 if (m_current) 126 if (m_current)
127 ptr = m_current->allocate(roundedSize); 127 ptr = m_current->allocate(roundedSize);
128 128
129 if (!ptr) { 129 if (!ptr) {
130 if (roundedSize > m_currentChunkSize) 130 if (roundedSize > m_currentChunkSize)
131 m_currentChunkSize = roundedSize; 131 m_currentChunkSize = roundedSize;
132 m_chunks.append( 132 m_chunks.push_back(
133 WTF::wrapUnique(new Chunk(m_allocator.get(), m_currentChunkSize))); 133 WTF::wrapUnique(new Chunk(m_allocator.get(), m_currentChunkSize)));
134 m_current = m_chunks.back().get(); 134 m_current = m_chunks.back().get();
135 ptr = m_current->allocate(roundedSize); 135 ptr = m_current->allocate(roundedSize);
136 } 136 }
137 return ptr; 137 return ptr;
138 } 138 }
139 139
140 // Rounds up the given allocation size to the specified alignment. 140 // Rounds up the given allocation size to the specified alignment.
141 size_t roundUp(size_t size, size_t alignment) { 141 size_t roundUp(size_t size, size_t alignment) {
142 ASSERT(!(alignment % 2)); 142 ASSERT(!(alignment % 2));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 RefPtr<Allocator> m_allocator; 185 RefPtr<Allocator> m_allocator;
186 Chunk* m_current; 186 Chunk* m_current;
187 size_t m_currentChunkSize; 187 size_t m_currentChunkSize;
188 Vector<std::unique_ptr<Chunk>> m_chunks; 188 Vector<std::unique_ptr<Chunk>> m_chunks;
189 }; 189 };
190 190
191 } // namespace blink 191 } // namespace blink
192 192
193 #endif // PODArena_h 193 #endif // PODArena_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/Language.cpp ('k') | third_party/WebKit/Source/platform/PODFreeListArenaTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698