From ca21a00c736d05686c84ab874ce6a49008da6a76 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Thu, 13 Feb 2014 18:35:54 +0000 Subject: SkWriter32: throw in the SkTDArray towel. I think it's looking more clear we don't have a clean way to use SkTDArray in SkWriter32. We can't give SkWriter32 meaningful control over SkTDArray's reallocation without making moot SkTDArray's raison d'etre. Let's just use an SkAutoTMalloc instead. It wants SkWriter32 to control it. Also, it's lower overhead: SkAutoTMalloc is just a smart poiter: no size or capacity stored. BUG=skia: R=reed@google.com, iancottrell@google.com, reed@chromium.org, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/163983002 git-svn-id: http://skia.googlecode.com/svn/trunk@13436 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/core/SkWriter32.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/core') diff --git a/src/core/SkWriter32.cpp b/src/core/SkWriter32.cpp index 46150ee752..fe33e4a39c 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); -- cgit v1.2.3