aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-13 18:35:54 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-13 18:35:54 +0000
commitca21a00c736d05686c84ab874ce6a49008da6a76 (patch)
tree5c116161612fdf72d000988b738dcdf1935f78e8 /src/core
parent989ac549c16d583297cd1d9ab814bfa59573b950 (diff)
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<uint8_t> instead. It wants SkWriter32 to control it. Also, it's lower overhead: SkAutoTMalloc<uint8_t> 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
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkWriter32.cpp12
1 files changed, 4 insertions, 8 deletions
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);