| Index: src/core/SkWriter32.cpp
|
| diff --git a/src/core/SkWriter32.cpp b/src/core/SkWriter32.cpp
|
| index 7285459c3d1e5767fff762d0bb38a4a6f848a2a0..0de8b20b250addf9059334a225aae0b5d5339fc1 100644
|
| --- a/src/core/SkWriter32.cpp
|
| +++ b/src/core/SkWriter32.cpp
|
| @@ -67,20 +67,20 @@ size_t SkWriter32::WriteStringSize(const char* str, size_t len) {
|
| return SkAlign4(lenBytes + len + 1);
|
| }
|
|
|
| +const size_t kMinBufferBytes=4096;
|
| +
|
| void SkWriter32::growToAtLeast(size_t size) {
|
| bool wasExternal = (fExternal != NULL) && (fData == fExternal);
|
| + fCapacity = kMinBufferBytes +
|
| + SkTMax(size, fCapacity + (fCapacity >> 1));
|
| +
|
| // cause the buffer to grow
|
| - fInternal.setCount(size);
|
| + fInternal.setCountExact(fCapacity);
|
| fData = fInternal.begin();
|
| if (wasExternal) {
|
| // we were external, so copy in the data
|
| memcpy(fData, fExternal, fUsed);
|
| }
|
| - // Find out the size the buffer grew to, it may be more than we asked for.
|
| - fCapacity = fInternal.reserved();
|
| - // Expand the array so all reserved space is "used", we maintain the
|
| - // amount we have written manually outside the array
|
| - fInternal.setCount(fCapacity);
|
| SkASSERT(fInternal.count() == fCapacity);
|
| SkASSERT(fInternal.reserved() == fCapacity);
|
| }
|
|
|