summaryrefslogtreecommitdiffstats
path: root/chrome/browser/bookmarks
diff options
context:
space:
mode:
authorjbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-07 20:42:56 +0000
committerjbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-07 20:42:56 +0000
commitce208f877048d4c7bbb57e0df045f0f39a9c80bf (patch)
tree24210ee34fc2c341d9d45c722e2941c9ab8ce768 /chrome/browser/bookmarks
parentd1f43abcb958e76806007d59f75f2da6078be89e (diff)
downloadchromium_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 'chrome/browser/bookmarks')
-rw-r--r--chrome/browser/bookmarks/bookmark_node_data.cc6
-rw-r--r--chrome/browser/bookmarks/bookmark_node_data.h5
2 files changed, 6 insertions, 5 deletions
diff --git a/chrome/browser/bookmarks/bookmark_node_data.cc b/chrome/browser/bookmarks/bookmark_node_data.cc
index 7d1d72f..14c77d3 100644
--- a/chrome/browser/bookmarks/bookmark_node_data.cc
+++ b/chrome/browser/bookmarks/bookmark_node_data.cc
@@ -55,7 +55,7 @@ void BookmarkNodeData::Element::WriteToPickle(Pickle* pickle) const {
}
bool BookmarkNodeData::Element::ReadFromPickle(Pickle* pickle,
- void** iterator) {
+ PickleIterator* iterator) {
std::string url_spec;
if (!pickle->ReadBool(iterator, &is_url) ||
!pickle->ReadString(iterator, &url_spec) ||
@@ -294,9 +294,9 @@ void BookmarkNodeData::WriteToPickle(Profile* profile, Pickle* pickle) const {
}
bool BookmarkNodeData::ReadFromPickle(Pickle* pickle) {
- void* data_iterator = NULL;
+ PickleIterator data_iterator(*pickle);
size_t element_count;
- if (profile_path_.ReadFromPickle(pickle, &data_iterator) &&
+ if (profile_path_.ReadFromPickle(&data_iterator) &&
pickle->ReadSize(&data_iterator, &element_count)) {
std::vector<Element> tmp_elements;
tmp_elements.resize(element_count);
diff --git a/chrome/browser/bookmarks/bookmark_node_data.h b/chrome/browser/bookmarks/bookmark_node_data.h
index 748e78a..5c1f9e6 100644
--- a/chrome/browser/bookmarks/bookmark_node_data.h
+++ b/chrome/browser/bookmarks/bookmark_node_data.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.
@@ -18,6 +18,7 @@
class BookmarkNode;
class Pickle;
+class PickleIterator;
class Profile;
// BookmarkNodeData is used to represent the following:
@@ -64,7 +65,7 @@ struct BookmarkNodeData {
// For reading/writing this Element.
void WriteToPickle(Pickle* pickle) const;
- bool ReadFromPickle(Pickle* pickle, void** iterator);
+ bool ReadFromPickle(Pickle* pickle, PickleIterator* iterator);
// ID of the node.
int64 id_;