Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(618)

Unified Diff: ui/base/clipboard/custom_data_helper.cc

Issue 9447084: Refactor Pickle Read methods to use higher performance PickleIterator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile (racing with incoming CLs) Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/clipboard/clipboard_unittest.cc ('k') | ui/base/dragdrop/gtk_dnd_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/clipboard/custom_data_helper.cc
diff --git a/ui/base/clipboard/custom_data_helper.cc b/ui/base/clipboard/custom_data_helper.cc
index 88abf0fba671e2d38cb2f4fd3ccf4ea73e60fbc2..5200de8e4de0298fd65e9a5dd4cf51d6aa29d371 100644
--- a/ui/base/clipboard/custom_data_helper.cc
+++ b/ui/base/clipboard/custom_data_helper.cc
@@ -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.
//
@@ -19,24 +19,20 @@ namespace {
class SkippablePickle : public Pickle {
public:
SkippablePickle(const void* data, size_t data_len);
- bool SkipString16(void** iter);
+ bool SkipString16(PickleIterator* iter);
};
SkippablePickle::SkippablePickle(const void* data, size_t data_len)
: Pickle(reinterpret_cast<const char*>(data), data_len) {
}
-bool SkippablePickle::SkipString16(void** iter) {
+bool SkippablePickle::SkipString16(PickleIterator* iter) {
DCHECK(iter);
int len;
if (!ReadLength(iter, &len))
return false;
- if (!IteratorHasRoomFor(*iter, len * sizeof(char16)))
- return false;
-
- UpdateIter(iter, len * sizeof(char16));
- return true;
+ return iter->SkipBytes(len * sizeof(char16));
}
} // namespace
@@ -45,7 +41,7 @@ void ReadCustomDataTypes(const void* data,
size_t data_length,
std::vector<string16>* types) {
SkippablePickle pickle(data, data_length);
- void* iter = NULL;
+ PickleIterator iter(pickle);
size_t size = 0;
if (!pickle.ReadSize(&iter, &size))
@@ -71,7 +67,7 @@ void ReadCustomDataForType(const void* data,
const string16& type,
string16* result) {
SkippablePickle pickle(data, data_length);
- void* iter = NULL;
+ PickleIterator iter(pickle);
size_t size = 0;
if (!pickle.ReadSize(&iter, &size))
@@ -94,7 +90,7 @@ void ReadCustomDataIntoMap(const void* data,
size_t data_length,
std::map<string16, string16>* result) {
Pickle pickle(reinterpret_cast<const char*>(data), data_length);
- void* iter = NULL;
+ PickleIterator iter(pickle);
size_t size = 0;
if (!pickle.ReadSize(&iter, &size))
« no previous file with comments | « ui/base/clipboard/clipboard_unittest.cc ('k') | ui/base/dragdrop/gtk_dnd_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698