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

Unified Diff: components/omnibox/search_suggestion_parser.cc

Issue 894033006: SearchSuggestionParser: Use a StringPiece instead of modifying a string. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@jsonstring-stringpiece
Patch Set: DeserializeJsonData accepts a StringPiece so there are 0 copies from the creation of the string. Created 5 years, 10 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 | « components/omnibox/search_suggestion_parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/omnibox/search_suggestion_parser.cc
diff --git a/components/omnibox/search_suggestion_parser.cc b/components/omnibox/search_suggestion_parser.cc
index d8452ee9465435f6046366ce829e6e5fe1dd27fe..57e041ce459eb189667a11170770f556299d2c34 100644
--- a/components/omnibox/search_suggestion_parser.cc
+++ b/components/omnibox/search_suggestion_parser.cc
@@ -343,14 +343,14 @@ std::string SearchSuggestionParser::ExtractJsonData(
// static
scoped_ptr<base::Value> SearchSuggestionParser::DeserializeJsonData(
- std::string json_data) {
+ base::StringPiece json_data) {
// The JSON response should be an array.
for (size_t response_start_index = json_data.find("["), i = 0;
- response_start_index != std::string::npos && i < 5;
+ response_start_index != base::StringPiece::npos && i < 5;
response_start_index = json_data.find("[", 1), i++) {
// Remove any XSSI guards to allow for JSON parsing.
if (response_start_index > 0)
Peter Kasting 2015/02/05 09:20:36 Nit: This conditional could just be removed and th
Matt Giuca 2015/02/06 00:30:02 Done.
- json_data.erase(0, response_start_index);
+ json_data.remove_prefix(response_start_index);
JSONStringValueSerializer deserializer(json_data);
deserializer.set_allow_trailing_comma(true);
« no previous file with comments | « components/omnibox/search_suggestion_parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698