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

Unified Diff: src/core/SkRWBuffer.cpp

Issue 2384763002: SkRWBuffer: preallocate 'initialCapacity' (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRWBuffer.cpp
diff --git a/src/core/SkRWBuffer.cpp b/src/core/SkRWBuffer.cpp
index 07a537a640a27173bea2093614bef8a468db0d01..41f1a287d20320351eaca3ab94096a5fe000e332 100644
--- a/src/core/SkRWBuffer.cpp
+++ b/src/core/SkRWBuffer.cpp
@@ -181,7 +181,12 @@ bool SkROBuffer::Iter::next() {
///////////////////////////////////////////////////////////////////////////////////////////////////
-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();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698