diff options
author | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-07 20:42:56 +0000 |
---|---|---|
committer | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-07 20:42:56 +0000 |
commit | ce208f877048d4c7bbb57e0df045f0f39a9c80bf (patch) | |
tree | 24210ee34fc2c341d9d45c722e2941c9ab8ce768 /ipc/param_traits_read_macros.h | |
parent | d1f43abcb958e76806007d59f75f2da6078be89e (diff) | |
download | chromium_src-ce208f877048d4c7bbb57e0df045f0f39a9c80bf.zip chromium_src-ce208f877048d4c7bbb57e0df045f0f39a9c80bf.tar.gz chromium_src-ce208f877048d4c7bbb57e0df045f0f39a9c80bf.tar.bz2 |
Refactor Pickle Read methods to use higher performance PickleIterator.
There was a lot of redundant error checking and initialization code in all Pickle Read methods because of the void** iterator type. This change replaces the void* iterator with PickleIterator, which encapsulates the read pointer so that less error checking and initialization code is needed for reading.
PickleIterator has all the necessary data to do the actual reading. The advantage of having it provide Read methods (as opposed to leaving them solely in the Pickle interface) is that the callers do not need to pass around the const Pickle* once they have a PickleIterator.
Followup CLs will refactor the call sites to remove const Pickle* arguments where they are now unnecessary. Then the Pickle::Read* methods can be removed entirely.
The alternative approach would have been to change the Pickle::Read methods to non-const and remove the iterator parameter (making Read methods advance an internal read pointer). Unfortunately, the const Read with iterator design is entrenched throughout the chromium code, making this a much more complex change with the same performance outcome.
BUG=13108
Review URL: https://chromiumcodereview.appspot.com/9447084
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125447 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/param_traits_read_macros.h')
-rw-r--r-- | ipc/param_traits_read_macros.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/ipc/param_traits_read_macros.h b/ipc/param_traits_read_macros.h index a78c880..9d89a92 100644 --- a/ipc/param_traits_read_macros.h +++ b/ipc/param_traits_read_macros.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -27,7 +27,7 @@ #undef IPC_STRUCT_TRAITS_END #define IPC_STRUCT_TRAITS_BEGIN(struct_name) \ bool ParamTraits<struct_name>:: \ - Read(const Message* m, void** iter, param_type* p) { \ + Read(const Message* m, PickleIterator* iter, param_type* p) { \ return #define IPC_STRUCT_TRAITS_MEMBER(name) ReadParam(m, iter, &p->name) && #define IPC_STRUCT_TRAITS_PARENT(type) ParamTraits<type>::Read(m, iter, p) && @@ -36,7 +36,7 @@ #undef IPC_ENUM_TRAITS #define IPC_ENUM_TRAITS(enum_name) \ bool ParamTraits<enum_name>:: \ - Read(const Message* m, void** iter, param_type* p) { \ + Read(const Message* m, PickleIterator* iter, param_type* p) { \ int type; \ if (!m->ReadInt(iter, &type)) \ return false; \ |