diff options
author | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-09 08:46:45 +0000 |
---|---|---|
committer | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-09 08:46:45 +0000 |
commit | 007b3f812fc9c989fb99d4a668d8bd9c7807ad81 (patch) | |
tree | 43e69dd0f4e4dbbe68afb6319fa18cee07a4be64 /chrome/renderer | |
parent | 2bde7e94eb8f402839145e48924391a5c645a554 (diff) | |
download | chromium_src-007b3f812fc9c989fb99d4a668d8bd9c7807ad81.zip chromium_src-007b3f812fc9c989fb99d4a668d8bd9c7807ad81.tar.gz chromium_src-007b3f812fc9c989fb99d4a668d8bd9c7807ad81.tar.bz2 |
Rewrite std::string("") to std::string(), Linux edition.
This patch was generated by running the empty_string clang tool
across the Chromium Linux compilation database. Implicitly or
explicitly constructing std::string() with a "" argument is
inefficient as the caller needs to emit extra instructions to
pass an argument, and the constructor needlessly copies a byte
into internal storage. Rewriting these instances to simply call
the default constructor appears to save ~14-18 kilobytes on an
optimized release build.
BUG=none
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=193020
Review URL: https://codereview.chromium.org/13145003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193040 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
11 files changed, 86 insertions, 87 deletions
diff --git a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc index 4a619f5..567c305 100644 --- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc +++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc @@ -251,7 +251,7 @@ TEST_F(PasswordAutofillAgentTest, NoInitialAutocompleteForReadOnly) { // Only the username should have been autocompleted. // TODO(jcivelli): may be we should not event fill the username? - CheckTextFieldsState(kAliceUsername, true, "", false); + CheckTextFieldsState(kAliceUsername, true, std::string(), false); } // Tests that having a non-matching username precludes the autocomplete. @@ -263,7 +263,7 @@ TEST_F(PasswordAutofillAgentTest, NoInitialAutocompleteForFilledField) { SimulateOnFillPasswordForm(fill_data_); // Neither field should be autocompleted. - CheckTextFieldsState("bogus", false, "", false); + CheckTextFieldsState("bogus", false, std::string(), false); } // Tests that having a matching username does not preclude the autocomplete. @@ -288,7 +288,7 @@ TEST_F(PasswordAutofillAgentTest, PasswordClearOnEdit) { SimulateUsernameChange("alicia", true); // The password should have been cleared. - CheckTextFieldsState("alicia", false, "", false); + CheckTextFieldsState("alicia", false, std::string(), false); } // Tests that we only autocomplete on focus lost and with a full username match @@ -299,27 +299,27 @@ TEST_F(PasswordAutofillAgentTest, WaitUsername) { SimulateOnFillPasswordForm(fill_data_); // No auto-fill should have taken place. - CheckTextFieldsState("", false, "", false); + CheckTextFieldsState(std::string(), false, std::string(), false); // No autocomplete should happen when text is entered in the username. SimulateUsernameChange("a", true); - CheckTextFieldsState("a", false, "", false); + CheckTextFieldsState("a", false, std::string(), false); SimulateUsernameChange("al", true); - CheckTextFieldsState("al", false, "", false); + CheckTextFieldsState("al", false, std::string(), false); SimulateUsernameChange(kAliceUsername, true); - CheckTextFieldsState(kAliceUsername, false, "", false); + CheckTextFieldsState(kAliceUsername, false, std::string(), false); // Autocomplete should happen only when the username textfield is blurred with // a full match. username_element_.setValue("a"); autofill_agent_->textFieldDidEndEditing(username_element_); - CheckTextFieldsState("a", false, "", false); + CheckTextFieldsState("a", false, std::string(), false); username_element_.setValue("al"); autofill_agent_->textFieldDidEndEditing(username_element_); - CheckTextFieldsState("al", false, "", false); + CheckTextFieldsState("al", false, std::string(), false); username_element_.setValue("alices"); autofill_agent_->textFieldDidEndEditing(username_element_); - CheckTextFieldsState("alices", false, "", false); + CheckTextFieldsState("alices", false, std::string(), false); username_element_.setValue(ASCIIToUTF16(kAliceUsername)); autofill_agent_->textFieldDidEndEditing(username_element_); CheckTextFieldsState(kAliceUsername, true, kAlicePassword, true); @@ -351,7 +351,7 @@ TEST_F(PasswordAutofillAgentTest, InlineAutocomplete) { // Test that deleting does not trigger autocomplete. SimulateKeyDownEvent(username_element_, ui::VKEY_BACK); SimulateUsernameChange("alic", true); - CheckTextFieldsState("alic", false, "", false); + CheckTextFieldsState("alic", false, std::string(), false); CheckUsernameSelection(4, 4); // No selection. // Reset the last pressed key to something other than backspace. SimulateKeyDownEvent(username_element_, ui::VKEY_A); @@ -361,7 +361,7 @@ TEST_F(PasswordAutofillAgentTest, InlineAutocomplete) { // practice the username should no longer be 'alice' and the selected range // should be empty. SimulateUsernameChange("alf", true); - CheckTextFieldsState("alf", false, "", false); + CheckTextFieldsState("alf", false, std::string(), false); CheckUsernameSelection(3, 3); // No selection. // Ok, so now the user removes all the text and enters the letter 'b'. @@ -379,7 +379,7 @@ TEST_F(PasswordAutofillAgentTest, InlineAutocomplete) { // want case-sensitive autocompletion, so the username and the selected range // should be empty. SimulateUsernameChange("c", true); - CheckTextFieldsState("c", false, "", false); + CheckTextFieldsState("c", false, std::string(), false); CheckUsernameSelection(1, 1); } @@ -419,7 +419,7 @@ TEST_F(PasswordAutofillAgentTest, SuggestionSelect) { WebKit::WebString(), 0); // Autocomplete should not have kicked in. - CheckTextFieldsState("", false, "", false); + CheckTextFieldsState(std::string(), false, std::string(), false); } } // namespace autofill diff --git a/chrome/renderer/automation/automation_renderer_helper_browsertest.cc b/chrome/renderer/automation/automation_renderer_helper_browsertest.cc index 659d312..65bd018 100644 --- a/chrome/renderer/automation/automation_renderer_helper_browsertest.cc +++ b/chrome/renderer/automation/automation_renderer_helper_browsertest.cc @@ -84,9 +84,9 @@ TEST_F(AutomationRendererHelperTest, RTLSnapshot) { } TEST_F(AutomationRendererHelperTest, ScriptChain) { - ScriptEvaluationRequest request("({'result': 10})", ""); - ScriptEvaluationRequest request_plus1( - "({'result': arguments[0].result + 1})", ""); + ScriptEvaluationRequest request("({'result': 10})", std::string()); + ScriptEvaluationRequest request_plus1("({'result': arguments[0].result + 1})", + std::string()); std::vector<ScriptEvaluationRequest> script_chain; script_chain.push_back(request); script_chain.push_back(request_plus1); @@ -102,10 +102,10 @@ TEST_F(AutomationRendererHelperTest, ScriptChain) { } TEST_F(AutomationRendererHelperTest, ScriptChainError) { - ScriptEvaluationRequest request("({'result': 10})", ""); + ScriptEvaluationRequest request("({'result': 10})", std::string()); ScriptEvaluationRequest error_request( "({'result': arguments[0].result + 1, 'error': {'msg': 'some msg'}})", - ""); + std::string()); std::vector<ScriptEvaluationRequest> script_chain; script_chain.push_back(request); script_chain.push_back(error_request); diff --git a/chrome/renderer/chrome_content_renderer_client_unittest.cc b/chrome/renderer/chrome_content_renderer_client_unittest.cc index b099eea..1387ff0 100644 --- a/chrome/renderer/chrome_content_renderer_client_unittest.cc +++ b/chrome/renderer/chrome_content_renderer_client_unittest.cc @@ -96,8 +96,8 @@ scoped_refptr<const extensions::Extension> CreateTestExtension( scoped_refptr<const extensions::Extension> CreateExtension( bool is_unrestricted, bool is_from_webstore) { - return CreateTestExtension(is_unrestricted, is_from_webstore, kNotHostedApp, - ""); + return CreateTestExtension( + is_unrestricted, is_from_webstore, kNotHostedApp, std::string()); } scoped_refptr<const extensions::Extension> CreateHostedApp( diff --git a/chrome/renderer/content_settings_observer_browsertest.cc b/chrome/renderer/content_settings_observer_browsertest.cc index f4777d2..8397c94 100644 --- a/chrome/renderer/content_settings_observer_browsertest.cc +++ b/chrome/renderer/content_settings_observer_browsertest.cc @@ -110,12 +110,11 @@ TEST_F(ChromeRenderViewTest, JSBlockSentAfterPageLoad) { ContentSettingsForOneType& script_setting_rules = content_setting_rules.script_rules; script_setting_rules.push_back( - ContentSettingPatternSource( - ContentSettingsPattern::Wildcard(), - ContentSettingsPattern::Wildcard(), - CONTENT_SETTING_BLOCK, - "", - false)); + ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), + ContentSettingsPattern::Wildcard(), + CONTENT_SETTING_BLOCK, + std::string(), + false)); ContentSettingsObserver* observer = ContentSettingsObserver::Get(view_); observer->SetContentSettingRules(&content_setting_rules); @@ -193,7 +192,7 @@ TEST_F(ChromeRenderViewTest, ImagesBlockedByDefault) { ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), CONTENT_SETTING_BLOCK, - "", + std::string(), false)); ContentSettingsObserver* observer = ContentSettingsObserver::Get(view_); @@ -211,7 +210,7 @@ TEST_F(ChromeRenderViewTest, ImagesBlockedByDefault) { ContentSettingsPattern::Wildcard(), ContentSettingsPattern::FromString(mock_observer.image_origin_), CONTENT_SETTING_ALLOW, - "", + std::string(), false)); EXPECT_CALL( @@ -236,7 +235,7 @@ TEST_F(ChromeRenderViewTest, ImagesAllowedByDefault) { ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), CONTENT_SETTING_ALLOW, - "", + std::string(), false)); ContentSettingsObserver* observer = ContentSettingsObserver::Get(view_); @@ -255,7 +254,7 @@ TEST_F(ChromeRenderViewTest, ImagesAllowedByDefault) { ContentSettingsPattern::Wildcard(), ContentSettingsPattern::FromString(mock_observer.image_origin_), CONTENT_SETTING_BLOCK, - "", + std::string(), false)); EXPECT_CALL(mock_observer, OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES, std::string())); @@ -270,12 +269,11 @@ TEST_F(ChromeRenderViewTest, ContentSettingsBlockScripts) { ContentSettingsForOneType& script_setting_rules = content_setting_rules.script_rules; script_setting_rules.push_back( - ContentSettingPatternSource( - ContentSettingsPattern::Wildcard(), - ContentSettingsPattern::Wildcard(), - CONTENT_SETTING_BLOCK, - "", - false)); + ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), + ContentSettingsPattern::Wildcard(), + CONTENT_SETTING_BLOCK, + std::string(), + false)); ContentSettingsObserver* observer = ContentSettingsObserver::Get(view_); observer->SetContentSettingRules(&content_setting_rules); @@ -306,12 +304,11 @@ TEST_F(ChromeRenderViewTest, ContentSettingsAllowScripts) { ContentSettingsForOneType& script_setting_rules = content_setting_rules.script_rules; script_setting_rules.push_back( - ContentSettingPatternSource( - ContentSettingsPattern::Wildcard(), - ContentSettingsPattern::Wildcard(), - CONTENT_SETTING_ALLOW, - "", - false)); + ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), + ContentSettingsPattern::Wildcard(), + CONTENT_SETTING_ALLOW, + std::string(), + false)); ContentSettingsObserver* observer = ContentSettingsObserver::Get(view_); observer->SetContentSettingRules(&content_setting_rules); @@ -343,18 +340,20 @@ TEST_F(ChromeRenderViewTest, ContentSettingsInterstitialPages) { ContentSettingsForOneType& script_setting_rules = content_setting_rules.script_rules; script_setting_rules.push_back( - ContentSettingPatternSource( - ContentSettingsPattern::Wildcard(), - ContentSettingsPattern::Wildcard(), - CONTENT_SETTING_BLOCK, "", false)); + ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), + ContentSettingsPattern::Wildcard(), + CONTENT_SETTING_BLOCK, + std::string(), + false)); // Block images. ContentSettingsForOneType& image_setting_rules = content_setting_rules.image_rules; image_setting_rules.push_back( - ContentSettingPatternSource( - ContentSettingsPattern::Wildcard(), - ContentSettingsPattern::Wildcard(), - CONTENT_SETTING_BLOCK, "", false)); + ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), + ContentSettingsPattern::Wildcard(), + CONTENT_SETTING_BLOCK, + std::string(), + false)); ContentSettingsObserver* observer = ContentSettingsObserver::Get(view_); observer->SetContentSettingRules(&content_setting_rules); diff --git a/chrome/renderer/extensions/chrome_v8_context.cc b/chrome/renderer/extensions/chrome_v8_context.cc index b4ae80e..5feff00 100644 --- a/chrome/renderer/extensions/chrome_v8_context.cc +++ b/chrome/renderer/extensions/chrome_v8_context.cc @@ -63,7 +63,7 @@ void ChromeV8Context::Invalidate() { } std::string ChromeV8Context::GetExtensionID() { - return extension_ ? extension_->id() : ""; + return extension_ ? extension_->id() : std::string(); } // static @@ -187,7 +187,7 @@ std::string ChromeV8Context::GetContextTypeDescription() { case Feature::WEB_PAGE_CONTEXT: return "WEB_PAGE"; } NOTREACHED(); - return ""; + return std::string(); } ChromeV8Context* ChromeV8Context::GetContext() { diff --git a/chrome/renderer/extensions/extension_helper.cc b/chrome/renderer/extensions/extension_helper.cc index a488cb7..ac456a8 100644 --- a/chrome/renderer/extensions/extension_helper.cc +++ b/chrome/renderer/extensions/extension_helper.cc @@ -313,8 +313,12 @@ void ExtensionHelper::OnExecuteCode( WebFrame* main_frame = webview->mainFrame(); if (!main_frame) { ListValue val; - Send(new ExtensionHostMsg_ExecuteCodeFinished( - routing_id(), params.request_id, "No main frame", -1, GURL(""), val)); + Send(new ExtensionHostMsg_ExecuteCodeFinished(routing_id(), + params.request_id, + "No main frame", + -1, + GURL(std::string()), + val)); return; } diff --git a/chrome/renderer/extensions/resource_request_policy.cc b/chrome/renderer/extensions/resource_request_policy.cc index 116b218..83ccb3f 100644 --- a/chrome/renderer/extensions/resource_request_policy.cc +++ b/chrome/renderer/extensions/resource_request_policy.cc @@ -51,7 +51,8 @@ bool ResourceRequestPolicy::CanRequestResource( // some extensions want to be able to do things like create their own // launchers. std::string resource_root_relative_path = - resource_url.path().empty() ? "" : resource_url.path().substr(1); + resource_url.path().empty() ? std::string() + : resource_url.path().substr(1); if (extension->is_hosted_app() && !IconsInfo::GetIcons(extension) .ContainsPath(resource_root_relative_path)) { diff --git a/chrome/renderer/extensions/user_script_scheduler.cc b/chrome/renderer/extensions/user_script_scheduler.cc index 3cb01ba..f194a23 100644 --- a/chrome/renderer/extensions/user_script_scheduler.cc +++ b/chrome/renderer/extensions/user_script_scheduler.cc @@ -147,13 +147,13 @@ void UserScriptScheduler::ExecuteCodeImpl( // Since extension info is sent separately from user script info, they can // be out of sync. We just ignore this situation. if (!extension) { - render_view->Send(new ExtensionHostMsg_ExecuteCodeFinished( - render_view->GetRoutingID(), - params.request_id, - "", // no error - -1, - GURL(""), - execution_results)); + render_view->Send( + new ExtensionHostMsg_ExecuteCodeFinished(render_view->GetRoutingID(), + params.request_id, + std::string(), // no error + -1, + GURL(std::string()), + execution_results)); return; } diff --git a/chrome/renderer/extensions/user_script_slave.cc b/chrome/renderer/extensions/user_script_slave.cc index f715207..3e64b7d 100644 --- a/chrome/renderer/extensions/user_script_slave.cc +++ b/chrome/renderer/extensions/user_script_slave.cc @@ -92,7 +92,7 @@ std::string UserScriptSlave::GetExtensionIdForIsolatedWorld( if (iter->second == isolated_world_id) return iter->first; } - return ""; + return std::string(); } // static diff --git a/chrome/renderer/plugins/plugin_uma_unittest.cc b/chrome/renderer/plugins/plugin_uma_unittest.cc index 99e6271..3b1950c 100644 --- a/chrome/renderer/plugins/plugin_uma_unittest.cc +++ b/chrome/renderer/plugins/plugin_uma_unittest.cc @@ -118,9 +118,8 @@ TEST_F(PluginUMATest, WidevineCdm) { } TEST_F(PluginUMATest, BySrcExtension) { - ExpectPluginType(PluginUMAReporter::QUICKTIME, - "", - GURL("file://file.mov")); + ExpectPluginType( + PluginUMAReporter::QUICKTIME, std::string(), GURL("file://file.mov")); // When plugin's mime type is given, we don't check extension. ExpectPluginType(PluginUMAReporter::UNSUPPORTED_MIMETYPE, @@ -128,40 +127,36 @@ TEST_F(PluginUMATest, BySrcExtension) { GURL("http://file.mov")); ExpectPluginType(PluginUMAReporter::WINDOWS_MEDIA_PLAYER, - "", + std::string(), GURL("file://file.asx")); - ExpectPluginType(PluginUMAReporter::REALPLAYER, - "", - GURL("file://file.rm")); + ExpectPluginType( + PluginUMAReporter::REALPLAYER, std::string(), GURL("file://file.rm")); ExpectPluginType(PluginUMAReporter::QUICKTIME, - "", + std::string(), GURL("http://aaa/file.mov?x=aaaa&y=b#c")); ExpectPluginType(PluginUMAReporter::QUICKTIME, - "", + std::string(), GURL("http://file.mov?x=aaaa&y=b#c")); ExpectPluginType(PluginUMAReporter::SHOCKWAVE_FLASH, - "", + std::string(), GURL("http://file.swf?x=aaaa&y=b#c")); ExpectPluginType(PluginUMAReporter::SHOCKWAVE_FLASH, - "", + std::string(), GURL("http://file.spl?x=aaaa&y=b#c")); ExpectPluginType(PluginUMAReporter::UNSUPPORTED_EXTENSION, - "", + std::string(), GURL("http://file.unknown_extension")); - ExpectPluginType(PluginUMAReporter::UNSUPPORTED_EXTENSION, - "", - GURL("http://")); - ExpectPluginType(PluginUMAReporter::UNSUPPORTED_EXTENSION, - "", - GURL("mov")); + ExpectPluginType( + PluginUMAReporter::UNSUPPORTED_EXTENSION, std::string(), GURL("http://")); + ExpectPluginType( + PluginUMAReporter::UNSUPPORTED_EXTENSION, std::string(), GURL("mov")); } TEST_F(PluginUMATest, CaseSensitivity) { ExpectPluginType(PluginUMAReporter::QUICKTIME, "video/QUICKTIME", GURL("http://file.aaa")); - ExpectPluginType(PluginUMAReporter::QUICKTIME, - "", - GURL("http://file.MoV")); + ExpectPluginType( + PluginUMAReporter::QUICKTIME, std::string(), GURL("http://file.MoV")); } diff --git a/chrome/renderer/safe_browsing/malware_dom_details_browsertest.cc b/chrome/renderer/safe_browsing/malware_dom_details_browsertest.cc index 034655f..8a120cb 100644 --- a/chrome/renderer/safe_browsing/malware_dom_details_browsertest.cc +++ b/chrome/renderer/safe_browsing/malware_dom_details_browsertest.cc @@ -97,7 +97,7 @@ TEST_F(MalwareDOMDetailsTest, Everything) { } { // >50 subframes, to verify kMaxNodes. - std::string html = ""; + std::string html; for (int i = 0; i < 55; ++i) { // The iframe contents is just a number. GURL iframe_url(base::StringPrintf("%s%d", urlprefix, i)); @@ -113,7 +113,7 @@ TEST_F(MalwareDOMDetailsTest, Everything) { } { // A page with >50 scripts, to verify kMaxNodes. - std::string html = ""; + std::string html; for (int i = 0; i < 55; ++i) { // The iframe contents is just a number. GURL script_url(base::StringPrintf("%s%d", urlprefix, i)); |