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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/TArrayTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkTArray.h
diff --git a/include/core/SkTArray.h b/include/core/SkTArray.h
index 9d410c12ea6940dc404ee1563ec325c64d2584d7..dea0e38fecae7e2ac10e0f0b7b517c2847e06364 100644
--- a/include/core/SkTArray.h
+++ b/include/core/SkTArray.h
@@ -273,6 +273,9 @@ public:
/** Swaps the contents of this array with that array. Does a pointer swap if possible,
otherwise copies the T values. */
void swap(SkTArray* that) {
+ if (this == that) {
+ return;
+ }
if (this->fPreAllocMemArray != this->fItemArray &&
that->fPreAllocMemArray != that->fItemArray) {
// If neither is using a preallocated array then just swap.
« 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