From 2de4626d5839e76e071029a25a0287b11ac6f0ef Mon Sep 17 00:00:00 2001 From: "mpcomplete@google.com" Date: Mon, 16 Mar 2009 20:21:57 +0000 Subject: Change Pickle to double its capacity by default, rather than increasing incrementally, when it needs to expand on writing data. BUG=8760 Review URL: http://codereview.chromium.org/46056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11769 0039d316-1c4b-4281-b951-d872f2087c98 --- base/pickle.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'base/pickle.cc') diff --git a/base/pickle.cc b/base/pickle.cc index d525e3f..1aeb1f4 100644 --- a/base/pickle.cc +++ b/base/pickle.cc @@ -263,7 +263,8 @@ char* Pickle::BeginWrite(size_t length) { size_t offset = AlignInt(header_->payload_size, sizeof(uint32)); size_t new_size = offset + length; - if (header_size_ + new_size > capacity_ && !Resize(header_size_ + new_size)) + size_t needed_size = header_size_ + new_size; + if (needed_size > capacity_ && !Resize(std::max(capacity_ * 2, needed_size))) return NULL; #ifdef ARCH_CPU_64_BITS -- cgit v1.1