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

Unified Diff: content/browser/webui/web_ui_impl.cc

Issue 2695873002: Prevent some string copies when sending Values to WebUI. (Closed)
Patch Set: Removed another copy Created 3 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 | « base/json/json_writer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/webui/web_ui_impl.cc
diff --git a/content/browser/webui/web_ui_impl.cc b/content/browser/webui/web_ui_impl.cc
index 3f06293ecd64801d4d2f4c58cfa1518f25118474..5e080a65aa73081aeb67164b71a9893cbcede584 100644
--- a/content/browser/webui/web_ui_impl.cc
+++ b/content/browser/webui/web_ui_impl.cc
@@ -55,17 +55,21 @@ const WebUI::TypeID WebUI::kNoWebUI = NULL;
base::string16 WebUI::GetJavascriptCall(
const std::string& function_name,
const std::vector<const base::Value*>& arg_list) {
- base::string16 parameters;
+ base::string16 result(base::ASCIIToUTF16(function_name));
+ result.push_back('(');
+
std::string json;
for (size_t i = 0; i < arg_list.size(); ++i) {
if (i > 0)
- parameters += base::char16(',');
+ result.push_back(',');
base::JSONWriter::Write(*arg_list[i], &json);
- parameters += base::UTF8ToUTF16(json);
+ result.append(base::UTF8ToUTF16(json));
}
- return base::ASCIIToUTF16(function_name) +
- base::char16('(') + parameters + base::char16(')') + base::char16(';');
+
+ result.push_back(')');
+ result.push_back(';');
+ return result;
}
WebUIImpl::WebUIImpl(WebContents* contents, const std::string& frame_name)
« no previous file with comments | « base/json/json_writer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698