summaryrefslogtreecommitdiffstats
path: root/base/pickle.cc
diff options
context:
space:
mode:
authormpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-16 20:21:57 +0000
committermpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-16 20:21:57 +0000
commit2de4626d5839e76e071029a25a0287b11ac6f0ef (patch)
treec69b188ba505ebc4bd9f315ef7d3798bfc84f4ed /base/pickle.cc
parentb65ce0948709317aadc38e18c1a16f23a72bb5eb (diff)
downloadchromium_src-2de4626d5839e76e071029a25a0287b11ac6f0ef.zip
chromium_src-2de4626d5839e76e071029a25a0287b11ac6f0ef.tar.gz
chromium_src-2de4626d5839e76e071029a25a0287b11ac6f0ef.tar.bz2
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
Diffstat (limited to 'base/pickle.cc')
-rw-r--r--base/pickle.cc3
1 files changed, 2 insertions, 1 deletions
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