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

Unified Diff: include/core/SkTDArray.h

Issue 163983002: SkWriter32: throw in the SkTDArray towel. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up scars in SkTDArray. Created 6 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 | include/core/SkWriter32.h » ('j') | 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 804b84f669df4e3d1e5ae7b645d9c6ea94e582e1..ecbfbd90e99f600b0d25dfd27821abf1671741e2 100644
--- a/include/core/SkTDArray.h
+++ b/include/core/SkTDArray.h
@@ -158,7 +158,6 @@ public:
* It will never shrink the shrink the storage.
*/
void setCount(int count) {
- // TODO(mtklein): eliminate this method, setCountExact -> setCount
SkASSERT(count >= 0);
if (count > fReserve) {
this->resizeStorageToAtLeast(count);
@@ -166,20 +165,6 @@ public:
fCount = count;
}
- /**
- * Sets the number of elements in the array.
- * If the array does not have space for count elements, it will increase
- * the storage allocated to exactly the amount required, with no remaining
- * reserved space.
- * It will never shrink the shrink the storage.
- */
- void setCountExact(int count) {
- if (count > fReserve) {
- this->resizeStorageToExact(count);
- }
- fCount = count;
- }
-
void setReserve(int reserve) {
if (reserve > fReserve) {
this->resizeStorageToAtLeast(reserve);
@@ -383,22 +368,6 @@ private:
}
/**
- * This resizes the storage to *exactly* count elements, growing or
- * shrinking the allocation as needed. It does not ASSERT anything about
- * the previous allocation size, or about fCount.
- *
- * note: does NOT modify fCount
- */
- void resizeStorageToExact(int count) {
- SkASSERT(count >= 0);
- fArray = (T*)sk_realloc_throw(fArray, count * sizeof(T));
-#ifdef SK_DEBUG
- fData = (ArrayT*)fArray;
-#endif
- fReserve = count;
- }
-
- /**
* Increase the storage allocation such that it can hold (fCount + extra)
* elements.
* It never shrinks the allocation, and it may increase the allocation by
@@ -408,9 +377,12 @@ private:
*/
void resizeStorageToAtLeast(int count) {
SkASSERT(count > fReserve);
- int space = count + 4;
- space += space>>2;
- this->resizeStorageToExact(space);
+ fReserve = count + 4;
+ fReserve += fReserve / 4;
+ fArray = (T*)sk_realloc_throw(fArray, fReserve * sizeof(T));
+#ifdef SK_DEBUG
+ fData = (ArrayT*)fArray;
+#endif
}
};
« no previous file with comments | « no previous file | include/core/SkWriter32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698