Pickle::Write* micro-optimizations
commitd1b319fc3f77e744fb325a5a28b6ae448072a9ae
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Thu, 31 Oct 2013 04:03:02 +0000 (31 04:03 +0000)
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Thu, 31 Oct 2013 04:03:02 +0000 (31 04:03 +0000)
treecd4b30de4c88a730eaf2fe04cf02c6b10f227a25
parenta979d27b84e0c363e0a3e640890a098374a5883b
Pickle::Write* micro-optimizations

Pickle is hot in some benchmarks. This helps by reworking WriteBytes in a few of ways:
1- Fold BeginWrite and EndWrite into WriteBytes since it's the only caller now.
2- keep track of the write offset, always aligned, separately, so that we can do alignment checks on the field sizes rather than the payload size (for next point).
3- provides a template version of WriteBytes with specializations for predefined sizes, that inline/optimize away alignment checks, padding, and memcpy.
4- change the meaning of capacity_ to not take the header size into account. This simplifies some arithmetic.

BUG=307480
R=jar@chromium.org

Review URL: https://codereview.chromium.org/34413002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231987 0039d316-1c4b-4281-b951-d872f2087c98
base/pickle.cc
base/pickle.h
base/pickle_unittest.cc