Index: include/core/SkTDArray.h |
diff --git a/include/core/SkTDArray.h b/include/core/SkTDArray.h |
index 67254ccc9a88fa93fe6489ea82bccb6efe8959e6..a9369192a7521761c84b10b9e69f0539d5d2b1c0 100644 |
--- a/include/core/SkTDArray.h |
+++ b/include/core/SkTDArray.h |
@@ -159,6 +159,13 @@ public: |
} |
} |
+ void setCountExact(int count) { |
+ if (count > fReserve) { |
+ this->growTo(count); |
+ } |
+ fCount = count; |
+ } |
+ |
void setReserve(int reserve) { |
if (reserve > fReserve) { |
SkASSERT(reserve > fCount); |
@@ -356,18 +363,20 @@ private: |
int fReserve; |
int fCount; |
+ void growTo(int size) { |
reed1
2014/02/07 15:37:49
/**
* This resizes the storage to *exactly* size
iancottrell
2014/02/07 16:54:15
Done.
|
+ fArray = (T*)sk_realloc_throw(fArray, size * sizeof(T)); |
+#ifdef SK_DEBUG |
+ fData = (ArrayT*)fArray; |
+#endif |
+ fReserve = size; |
+ } |
+ |
void growBy(int extra) { |
reed1
2014/02/07 15:37:49
/**
* Increase the storage allocation such it can
iancottrell
2014/02/07 16:54:15
Done.
|
SkASSERT(extra); |
if (fCount + extra > fReserve) { |
int size = fCount + extra + 4; |
- size += size >> 2; |
- |
- fArray = (T*)sk_realloc_throw(fArray, size * sizeof(T)); |
-#ifdef SK_DEBUG |
- fData = (ArrayT*)fArray; |
-#endif |
- fReserve = size; |
+ growTo(size + (size >> 2)); |
} |
fCount += extra; |
} |