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

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: Unconditionally call remove_prefix, since there is no penalty. 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 7e06d950ce574aba956dbe9323c34df7927e2542..a554fbc3aaeb2d290887a8d85b59ac402d407d44 100644
--- a/components/omnibox/search_suggestion_parser.cc
+++ b/components/omnibox/search_suggestion_parser.cc
@@ -343,14 +343,13 @@ 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)
- 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