From ce208f877048d4c7bbb57e0df045f0f39a9c80bf Mon Sep 17 00:00:00 2001 From: "jbates@chromium.org" Date: Wed, 7 Mar 2012 20:42:56 +0000 Subject: 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 --- base/file_path.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'base/file_path.cc') diff --git a/base/file_path.cc b/base/file_path.cc index c4f1c54..3b1fca4 100644 --- a/base/file_path.cc +++ b/base/file_path.cc @@ -586,12 +586,12 @@ void FilePath::WriteToPickle(Pickle* pickle) { #endif } -bool FilePath::ReadFromPickle(Pickle* pickle, void** iter) { +bool FilePath::ReadFromPickle(PickleIterator* iter) { #if defined(OS_WIN) - if (!pickle->ReadString16(iter, &path_)) + if (!iter->ReadString16(&path_)) return false; #else - if (!pickle->ReadString(iter, &path_)) + if (!iter->ReadString(&path_)) return false; #endif -- cgit v1.1