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

Unified Diff: include/core/SkTDArray.h

Issue 563633003: Assert SkTDArray::pop() doesn't underflow. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkTDArray.h
diff --git a/include/core/SkTDArray.h b/include/core/SkTDArray.h
index 4c90460b947f25809e0c21084fff7b924c3c78e1..92f297c31a63f6a2f0c927f01c2db5ac6f69215e 100644
--- a/include/core/SkTDArray.h
+++ b/include/core/SkTDArray.h
@@ -282,12 +282,12 @@ public:
}
// routines to treat the array like a stack
- T* push() { return this->append(); }
- void push(const T& elem) { *this->append() = elem; }
- const T& top() const { return (*this)[fCount - 1]; }
- T& top() { return (*this)[fCount - 1]; }
- void pop(T* elem) { if (elem) *elem = (*this)[fCount - 1]; --fCount; }
- void pop() { --fCount; }
+ T* push() { return this->append(); }
+ void push(const T& elem) { *this->append() = elem; }
+ const T& top() const { return (*this)[fCount - 1]; }
+ T& top() { return (*this)[fCount - 1]; }
+ void pop(T* elem) { SkASSERT(fCount > 0); if (elem) *elem = (*this)[fCount - 1]; --fCount; }
+ void pop() { SkASSERT(fCount > 0); --fCount; }
void deleteAll() {
T* iter = fArray;
« 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