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

Unified Diff: base/pickle.cc

Issue 35893002: IPC pickling optimization for render passes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ccmessagesperf-reserve: nits Created 7 years, 2 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 | « base/pickle.h ('k') | content/common/cc_messages.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/pickle.cc
diff --git a/base/pickle.cc b/base/pickle.cc
index af3191b9d86db2785fe375ecbcb045cf0a420870..abb561ffb5553da1c16b6c8b7e342217e4f3a57c 100644
--- a/base/pickle.cc
+++ b/base/pickle.cc
@@ -304,8 +304,18 @@ void Pickle::TrimWriteData(int new_length) {
*cur_length = new_length;
}
+void Pickle::Reserve(size_t additional_capacity) {
+ // Write at a uint32-aligned offset from the beginning of the header.
+ size_t offset = AlignInt(header_->payload_size, sizeof(uint32));
+
+ size_t new_size = offset + additional_capacity;
+ size_t needed_size = header_size_ + new_size;
+ if (needed_size > capacity_)
+ Resize(capacity_ * 2 + needed_size);
+}
+
char* Pickle::BeginWrite(size_t length) {
- // write at a uint32-aligned offset from the beginning of the header
+ // Write at a uint32-aligned offset from the beginning of the header.
size_t offset = AlignInt(header_->payload_size, sizeof(uint32));
size_t new_size = offset + length;
« no previous file with comments | « base/pickle.h ('k') | content/common/cc_messages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698