SkRWBuffer: preallocate 'initialCapacity'
We're currently ignoring the hint, resulting in multiple unneeded
allocations later.
BUG=chromium:651698
R=scroggo@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2384763002
Review-Url: https://codereview.chromium.org/2384763002
diff --git a/src/core/SkRWBuffer.cpp b/src/core/SkRWBuffer.cpp
index 07a537a..41f1a28 100644
--- a/src/core/SkRWBuffer.cpp
+++ b/src/core/SkRWBuffer.cpp
@@ -181,7 +181,12 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
-SkRWBuffer::SkRWBuffer(size_t initialCapacity) : fHead(nullptr), fTail(nullptr), fTotalUsed(0) {}
+SkRWBuffer::SkRWBuffer(size_t initialCapacity) : fHead(nullptr), fTail(nullptr), fTotalUsed(0) {
+ if (initialCapacity) {
+ fHead = SkBufferHead::Alloc(initialCapacity);
+ fTail = &fHead->fBlock;
+ }
+}
SkRWBuffer::~SkRWBuffer() {
this->validate();