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

Side by Side Diff: include/private/SkTArray.h

Issue 1902423007: Fix indentation and casts in SkTArray. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkTArray_DEFINED 8 #ifndef SkTArray_DEFINED
9 #define SkTArray_DEFINED 9 #define SkTArray_DEFINED
10 10
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 return *new (newT) T(std::forward<Args>(args)...); 187 return *new (newT) T(std::forward<Args>(args)...);
188 } 188 }
189 189
190 /** 190 /**
191 * Allocates n more default-initialized T values, and returns the address of 191 * Allocates n more default-initialized T values, and returns the address of
192 * the start of that new range. Note: this address is only valid until the 192 * the start of that new range. Note: this address is only valid until the
193 * next API call made on the array that might add or remove elements. 193 * next API call made on the array that might add or remove elements.
194 */ 194 */
195 T* push_back_n(int n) { 195 T* push_back_n(int n) {
196 SkASSERT(n >= 0); 196 SkASSERT(n >= 0);
197 char* newTs = static_cast<char*>(this->push_back_raw(n)); 197 void* newTs = this->push_back_raw(n);
198 for (int i = 0; i < n; ++i) { 198 for (int i = 0; i < n; ++i) {
199 new (newTs + i * sizeof(T)) T; 199 new (static_cast<char*>(newTs) + i * sizeof(T)) T;
200 } 200 }
201 return reinterpret_cast<T*>(newTs); 201 return static_cast<T*>(newTs);
202 } 202 }
203 203
204 /** 204 /**
205 * Version of above that uses a copy constructor to initialize all n items 205 * Version of above that uses a copy constructor to initialize all n items
206 * to the same T. 206 * to the same T.
207 */ 207 */
208 T* push_back_n(int n, const T& t) { 208 T* push_back_n(int n, const T& t) {
209 SkASSERT(n >= 0); 209 SkASSERT(n >= 0);
210 char* newTs = static_cast<char*>(this->push_back_raw(n)); 210 void* newTs = this->push_back_raw(n);
211 for (int i = 0; i < n; ++i) { 211 for (int i = 0; i < n; ++i) {
212 new (newTs + i * sizeof(T)) T(t); 212 new (static_cast<char*>(newTs) + i * sizeof(T)) T(t);
213 } 213 }
214 return reinterpret_cast<T*>(newTs); 214 return static_cast<T*>(newTs);
215 } 215 }
216 216
217 /** 217 /**
218 * Version of above that uses a copy constructor to initialize the n items 218 * Version of above that uses a copy constructor to initialize the n items
219 * to separate T values. 219 * to separate T values.
220 */ 220 */
221 T* push_back_n(int n, const T t[]) { 221 T* push_back_n(int n, const T t[]) {
222 SkASSERT(n >= 0); 222 SkASSERT(n >= 0);
223 this->checkRealloc(n); 223 this->checkRealloc(n);
224 for (int i = 0; i < n; ++i) { 224 for (int i = 0; i < n; ++i) {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 SkSTArray& operator= (const INHERITED& array) { 529 SkSTArray& operator= (const INHERITED& array) {
530 INHERITED::operator=(array); 530 INHERITED::operator=(array);
531 return *this; 531 return *this;
532 } 532 }
533 533
534 private: 534 private:
535 SkAlignedSTStorage<N,T> fStorage; 535 SkAlignedSTStorage<N,T> fStorage;
536 }; 536 };
537 537
538 #endif 538 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698