summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-09 05:45:17 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-09 05:45:17 +0000
commite59558b78e8c6a1b0bd916a724724b638c3c91b6 (patch)
tree712268a7e9e1cd552f309d89641b2bed5ad06322 /extensions
parent31fcd34da3797bc49160620ef8c94a38652c0587 (diff)
downloadchromium_src-e59558b78e8c6a1b0bd916a724724b638c3c91b6.zip
chromium_src-e59558b78e8c6a1b0bd916a724724b638c3c91b6.tar.gz
chromium_src-e59558b78e8c6a1b0bd916a724724b638c3c91b6.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 Review URL: https://codereview.chromium.org/13145003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193020 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions')
-rw-r--r--extensions/common/extension_resource_unittest.cc3
-rw-r--r--extensions/common/matcher/substring_set_matcher_unittest.cc2
-rw-r--r--extensions/common/matcher/url_matcher.cc4
-rw-r--r--extensions/common/matcher/url_matcher_factory.cc3
-rw-r--r--extensions/common/matcher/url_matcher_unittest.cc51
5 files changed, 35 insertions, 28 deletions
diff --git a/extensions/common/extension_resource_unittest.cc b/extensions/common/extension_resource_unittest.cc
index 132e718..3791b14 100644
--- a/extensions/common/extension_resource_unittest.cc
+++ b/extensions/common/extension_resource_unittest.cc
@@ -131,7 +131,8 @@ TEST(ExtensionResourceTest, CreateWithAllResourcesOnDisk) {
ASSERT_TRUE(file_util::CreateDirectory(l10n_path));
std::vector<std::string> locales;
- l10n_util::GetParentLocales(l10n_util::GetApplicationLocale(""), &locales);
+ l10n_util::GetParentLocales(l10n_util::GetApplicationLocale(std::string()),
+ &locales);
ASSERT_FALSE(locales.empty());
for (size_t i = 0; i < locales.size(); i++) {
base::FilePath make_path;
diff --git a/extensions/common/matcher/substring_set_matcher_unittest.cc b/extensions/common/matcher/substring_set_matcher_unittest.cc
index 4152ff9..fde65bf 100644
--- a/extensions/common/matcher/substring_set_matcher_unittest.cc
+++ b/extensions/common/matcher/substring_set_matcher_unittest.cc
@@ -117,7 +117,7 @@ TEST(SubstringSetMatcherTest, TestMatcher) {
// String abcde
// Pattern 1
// Pattern 2 abcdef
- TestTwoPatterns("abcde", "", "abcdef", true, false);
+ TestTwoPatterns("abcde", std::string(), "abcdef", true, false);
}
TEST(SubstringSetMatcherTest, RegisterAndRemove) {
diff --git a/extensions/common/matcher/url_matcher.cc b/extensions/common/matcher/url_matcher.cc
index d7779a2..b599293 100644
--- a/extensions/common/matcher/url_matcher.cc
+++ b/extensions/common/matcher/url_matcher.cc
@@ -256,8 +256,8 @@ URLMatcherConditionFactory::~URLMatcherConditionFactory() {
std::string URLMatcherConditionFactory::CanonicalizeURLForComponentSearches(
const GURL& url) const {
return kBeginningOfURL + CanonicalizeHostname(url.host()) + kEndOfDomain +
- url.path() + kEndOfPath + (url.has_query() ? "?" + url.query() : "") +
- kEndOfURL;
+ url.path() + kEndOfPath +
+ (url.has_query() ? "?" + url.query() : std::string()) + kEndOfURL;
}
URLMatcherCondition URLMatcherConditionFactory::CreateHostPrefixCondition(
diff --git a/extensions/common/matcher/url_matcher_factory.cc b/extensions/common/matcher/url_matcher_factory.cc
index cdd08ba..3ca4aa2 100644
--- a/extensions/common/matcher/url_matcher_factory.cc
+++ b/extensions/common/matcher/url_matcher_factory.cc
@@ -151,7 +151,8 @@ URLMatcherFactory::CreateFromURLFilterDictionary(
// matched.
if (url_matcher_conditions.empty()) {
url_matcher_conditions.insert(
- url_matcher_condition_factory->CreateHostPrefixCondition(""));
+ url_matcher_condition_factory->CreateHostPrefixCondition(
+ std::string()));
}
scoped_refptr<URLMatcherConditionSet> url_matcher_condition_set(
diff --git a/extensions/common/matcher/url_matcher_unittest.cc b/extensions/common/matcher/url_matcher_unittest.cc
index 09fc562..b17c13c 100644
--- a/extensions/common/matcher/url_matcher_unittest.cc
+++ b/extensions/common/matcher/url_matcher_unittest.cc
@@ -247,7 +247,7 @@ TEST(URLMatcherConditionFactoryTest, TestComponentSearches) {
std::string url = factory.CanonicalizeURLForComponentSearches(gurl);
// Test host component.
- EXPECT_TRUE(Matches(factory.CreateHostPrefixCondition(""), url));
+ EXPECT_TRUE(Matches(factory.CreateHostPrefixCondition(std::string()), url));
EXPECT_TRUE(Matches(factory.CreateHostPrefixCondition("www.goog"), url));
EXPECT_TRUE(
Matches(factory.CreateHostPrefixCondition("www.google.com"), url));
@@ -258,7 +258,7 @@ TEST(URLMatcherConditionFactoryTest, TestComponentSearches) {
Matches(factory.CreateHostPrefixCondition("www.google.com/"), url));
EXPECT_FALSE(Matches(factory.CreateHostPrefixCondition("webhp"), url));
- EXPECT_TRUE(Matches(factory.CreateHostSuffixCondition(""), url));
+ EXPECT_TRUE(Matches(factory.CreateHostSuffixCondition(std::string()), url));
EXPECT_TRUE(Matches(factory.CreateHostSuffixCondition("com"), url));
EXPECT_TRUE(Matches(factory.CreateHostSuffixCondition(".com"), url));
EXPECT_TRUE(
@@ -270,7 +270,7 @@ TEST(URLMatcherConditionFactoryTest, TestComponentSearches) {
Matches(factory.CreateHostSuffixCondition("www.google.com/"), url));
EXPECT_FALSE(Matches(factory.CreateHostSuffixCondition("webhp"), url));
- EXPECT_FALSE(Matches(factory.CreateHostEqualsCondition(""), url));
+ EXPECT_FALSE(Matches(factory.CreateHostEqualsCondition(std::string()), url));
EXPECT_FALSE(Matches(factory.CreateHostEqualsCondition("www"), url));
EXPECT_TRUE(
Matches(factory.CreateHostEqualsCondition("www.google.com"), url));
@@ -279,14 +279,14 @@ TEST(URLMatcherConditionFactoryTest, TestComponentSearches) {
// Test path component.
- EXPECT_TRUE(Matches(factory.CreatePathPrefixCondition(""), url));
+ EXPECT_TRUE(Matches(factory.CreatePathPrefixCondition(std::string()), url));
EXPECT_TRUE(Matches(factory.CreatePathPrefixCondition("/web"), url));
EXPECT_TRUE(Matches(factory.CreatePathPrefixCondition("/webhp"), url));
EXPECT_FALSE(Matches(factory.CreatePathPrefixCondition("webhp"), url));
EXPECT_FALSE(Matches(factory.CreatePathPrefixCondition("/webhp?"), url));
EXPECT_FALSE(Matches(factory.CreatePathPrefixCondition("?sourceid"), url));
- EXPECT_TRUE(Matches(factory.CreatePathSuffixCondition(""), url));
+ EXPECT_TRUE(Matches(factory.CreatePathSuffixCondition(std::string()), url));
EXPECT_TRUE(Matches(factory.CreatePathSuffixCondition("webhp"), url));
EXPECT_TRUE(Matches(factory.CreatePathSuffixCondition("/webhp"), url));
EXPECT_FALSE(Matches(factory.CreatePathSuffixCondition("/web"), url));
@@ -300,12 +300,12 @@ TEST(URLMatcherConditionFactoryTest, TestComponentSearches) {
// Test query component.
- EXPECT_TRUE(Matches(factory.CreateQueryPrefixCondition(""), url));
+ EXPECT_TRUE(Matches(factory.CreateQueryPrefixCondition(std::string()), url));
EXPECT_TRUE(Matches(factory.CreateQueryPrefixCondition("sourceid"), url));
// The '?' at the beginning is just ignored.
EXPECT_TRUE(Matches(factory.CreateQueryPrefixCondition("?sourceid"), url));
- EXPECT_TRUE(Matches(factory.CreateQuerySuffixCondition(""), url));
+ EXPECT_TRUE(Matches(factory.CreateQuerySuffixCondition(std::string()), url));
EXPECT_TRUE(Matches(factory.CreateQuerySuffixCondition("ion=1"), url));
EXPECT_FALSE(Matches(factory.CreateQuerySuffixCondition("www"), url));
// "Suffix" condition + pattern starting with '?' = "equals" condition.
@@ -330,21 +330,26 @@ TEST(URLMatcherConditionFactoryTest, TestComponentSearches) {
// Test adjacent components
EXPECT_TRUE(Matches(factory.CreateHostSuffixPathPrefixCondition(
"google.com", "/webhp"), url));
- EXPECT_TRUE(Matches(factory.CreateHostSuffixPathPrefixCondition(
- "", "/webhp"), url));
- EXPECT_TRUE(Matches(factory.CreateHostSuffixPathPrefixCondition(
- "google.com", ""), url));
- EXPECT_FALSE(Matches(factory.CreateHostSuffixPathPrefixCondition(
- "www", ""), url));
+ EXPECT_TRUE(Matches(
+ factory.CreateHostSuffixPathPrefixCondition(std::string(), "/webhp"),
+ url));
+ EXPECT_TRUE(Matches(
+ factory.CreateHostSuffixPathPrefixCondition("google.com", std::string()),
+ url));
+ EXPECT_FALSE(Matches(
+ factory.CreateHostSuffixPathPrefixCondition("www", std::string()), url));
EXPECT_TRUE(Matches(factory.CreateHostEqualsPathPrefixCondition(
"www.google.com", "/webhp"), url));
- EXPECT_FALSE(Matches(factory.CreateHostEqualsPathPrefixCondition(
- "", "/webhp"), url));
+ EXPECT_FALSE(Matches(
+ factory.CreateHostEqualsPathPrefixCondition(std::string(), "/webhp"),
+ url));
EXPECT_TRUE(Matches(factory.CreateHostEqualsPathPrefixCondition(
- "www.google.com", ""), url));
- EXPECT_FALSE(Matches(factory.CreateHostEqualsPathPrefixCondition(
- "google.com", ""), url));
+ "www.google.com", std::string()),
+ url));
+ EXPECT_FALSE(Matches(
+ factory.CreateHostEqualsPathPrefixCondition("google.com", std::string()),
+ url));
}
TEST(URLMatcherConditionFactoryTest, TestFullSearches) {
@@ -354,9 +359,9 @@ TEST(URLMatcherConditionFactoryTest, TestFullSearches) {
URLMatcherConditionFactory factory;
std::string url = factory.CanonicalizeURLForFullSearches(gurl);
- EXPECT_TRUE(Matches(factory.CreateURLPrefixCondition(""), url));
- EXPECT_TRUE(Matches(factory.CreateURLPrefixCondition(
- "https://www.goog"), url));
+ EXPECT_TRUE(Matches(factory.CreateURLPrefixCondition(std::string()), url));
+ EXPECT_TRUE(
+ Matches(factory.CreateURLPrefixCondition("https://www.goog"), url));
EXPECT_TRUE(Matches(factory.CreateURLPrefixCondition(
"https://www.google.com"), url));
EXPECT_TRUE(Matches(factory.CreateURLPrefixCondition(
@@ -365,11 +370,11 @@ TEST(URLMatcherConditionFactoryTest, TestFullSearches) {
"http://www.google.com"), url));
EXPECT_FALSE(Matches(factory.CreateURLPrefixCondition("webhp"), url));
- EXPECT_TRUE(Matches(factory.CreateURLSuffixCondition(""), url));
+ EXPECT_TRUE(Matches(factory.CreateURLSuffixCondition(std::string()), url));
EXPECT_TRUE(Matches(factory.CreateURLSuffixCondition("ion=1"), url));
EXPECT_FALSE(Matches(factory.CreateURLSuffixCondition("www"), url));
- EXPECT_TRUE(Matches(factory.CreateURLContainsCondition(""), url));
+ EXPECT_TRUE(Matches(factory.CreateURLContainsCondition(std::string()), url));
EXPECT_TRUE(Matches(factory.CreateURLContainsCondition("www.goog"), url));
EXPECT_TRUE(Matches(factory.CreateURLContainsCondition("webhp"), url));
EXPECT_TRUE(Matches(factory.CreateURLContainsCondition("?"), url));