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

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

Issue 909583003: Add tests for STArray swap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix int/size_t warnings Created 5 years, 10 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 | tests/TArrayTest.cpp » ('j') | 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 if (newCount > fCount) { 266 if (newCount > fCount) {
267 this->push_back_n(newCount - fCount); 267 this->push_back_n(newCount - fCount);
268 } else if (newCount < fCount) { 268 } else if (newCount < fCount) {
269 this->pop_back_n(fCount - newCount); 269 this->pop_back_n(fCount - newCount);
270 } 270 }
271 } 271 }
272 272
273 /** Swaps the contents of this array with that array. Does a pointer swap if possible, 273 /** Swaps the contents of this array with that array. Does a pointer swap if possible,
274 otherwise copies the T values. */ 274 otherwise copies the T values. */
275 void swap(SkTArray* that) { 275 void swap(SkTArray* that) {
276 if (this == that) {
277 return;
278 }
276 if (this->fPreAllocMemArray != this->fItemArray && 279 if (this->fPreAllocMemArray != this->fItemArray &&
277 that->fPreAllocMemArray != that->fItemArray) { 280 that->fPreAllocMemArray != that->fItemArray) {
278 // If neither is using a preallocated array then just swap. 281 // If neither is using a preallocated array then just swap.
279 SkTSwap(fItemArray, that->fItemArray); 282 SkTSwap(fItemArray, that->fItemArray);
280 SkTSwap(fCount, that->fCount); 283 SkTSwap(fCount, that->fCount);
281 SkTSwap(fAllocCount, that->fAllocCount); 284 SkTSwap(fAllocCount, that->fAllocCount);
282 } else { 285 } else {
283 // This could be more optimal... 286 // This could be more optimal...
284 SkTArray copy(*that); 287 SkTArray copy(*that);
285 *that = *this; 288 *that = *this;
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 SkSTArray& operator= (const INHERITED& array) { 540 SkSTArray& operator= (const INHERITED& array) {
538 INHERITED::operator=(array); 541 INHERITED::operator=(array);
539 return *this; 542 return *this;
540 } 543 }
541 544
542 private: 545 private:
543 SkAlignedSTStorage<N,T> fStorage; 546 SkAlignedSTStorage<N,T> fStorage;
544 }; 547 };
545 548
546 #endif 549 #endif
OLDNEW
« no previous file with comments | « no previous file | tests/TArrayTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698