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

Unified Diff: src/core/SkWriter32.cpp

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 | « include/core/SkWriter32.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkWriter32.cpp
diff --git a/src/core/SkWriter32.cpp b/src/core/SkWriter32.cpp
index 46150ee7522ba0f6a45487b0caf790f214d77bcb..fe33e4a39cf011d1ce54d1d9a08c321d99f707fe 100644
--- a/src/core/SkWriter32.cpp
+++ b/src/core/SkWriter32.cpp
@@ -63,17 +63,13 @@ 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) {
const bool wasExternal = (fExternal != NULL) && (fData == fExternal);
- const size_t minCapacity = kMinBufferBytes +
- SkTMax(size, fCapacity + (fCapacity >> 1));
- // cause the buffer to grow
- fInternal.setCountExact(minCapacity);
- fData = fInternal.begin();
- fCapacity = fInternal.reserved();
+ fCapacity = 4096 + SkTMax(size, fCapacity + (fCapacity / 2));
+ fInternal.realloc(fCapacity);
+ fData = fInternal.get();
+
if (wasExternal) {
// we were external, so copy in the data
memcpy(fData, fExternal, fUsed);
« no previous file with comments | « include/core/SkWriter32.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698