summaryrefslogtreecommitdiffstats
path: root/dbus
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-09 08:46:45 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-09 08:46:45 +0000
commit007b3f812fc9c989fb99d4a668d8bd9c7807ad81 (patch)
tree43e69dd0f4e4dbbe68afb6319fa18cee07a4be64 /dbus
parent2bde7e94eb8f402839145e48924391a5c645a554 (diff)
downloadchromium_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 'dbus')
-rw-r--r--dbus/end_to_end_async_unittest.cc4
-rw-r--r--dbus/message.cc6
-rw-r--r--dbus/message_unittest.cc6
-rw-r--r--dbus/string_util_unittest.cc2
-rw-r--r--dbus/values_util.cc2
5 files changed, 10 insertions, 10 deletions
diff --git a/dbus/end_to_end_async_unittest.cc b/dbus/end_to_end_async_unittest.cc
index 0a3446e..6943494 100644
--- a/dbus/end_to_end_async_unittest.cc
+++ b/dbus/end_to_end_async_unittest.cc
@@ -185,7 +185,7 @@ class EndToEndAsyncTest : public testing::Test {
ASSERT_TRUE(reader.PopString(&response_string));
response_strings_.push_back(response_string);
} else {
- response_strings_.push_back("");
+ response_strings_.push_back(std::string());
}
message_loop_.Quit();
};
@@ -205,7 +205,7 @@ class EndToEndAsyncTest : public testing::Test {
ASSERT_NE("", error->GetErrorName());
error_names_.push_back(error->GetErrorName());
} else {
- error_names_.push_back("");
+ error_names_.push_back(std::string());
}
message_loop_.Quit();
}
diff --git a/dbus/message.cc b/dbus/message.cc
index ce53a48..737b0c4 100644
--- a/dbus/message.cc
+++ b/dbus/message.cc
@@ -87,7 +87,7 @@ std::string Message::GetMessageTypeAsString() {
return "MESSAGE_ERROR";
}
NOTREACHED();
- return "";
+ return std::string();
}
std::string Message::ToStringInternal(const std::string& indent,
@@ -251,7 +251,7 @@ std::string Message::ToStringInternal(const std::string& indent,
// ...
std::string Message::ToString() {
if (!raw_message_)
- return "";
+ return std::string();
// Generate headers first.
std::string headers;
@@ -268,7 +268,7 @@ std::string Message::ToString() {
// Generate the payload.
MessageReader reader(this);
- return headers + "\n" + ToStringInternal("", &reader);
+ return headers + "\n" + ToStringInternal(std::string(), &reader);
}
bool Message::SetDestination(const std::string& destination) {
diff --git a/dbus/message_unittest.cc b/dbus/message_unittest.cc
index 7e4455a8..383e1c1 100644
--- a/dbus/message_unittest.cc
+++ b/dbus/message_unittest.cc
@@ -557,7 +557,7 @@ TEST(MessageTest, GetAndSetHeaders) {
scoped_ptr<dbus::Response> message(dbus::Response::CreateEmpty());
EXPECT_EQ("", message->GetDestination());
- EXPECT_EQ(dbus::ObjectPath(""), message->GetPath());
+ EXPECT_EQ(dbus::ObjectPath(std::string()), message->GetPath());
EXPECT_EQ("", message->GetInterface());
EXPECT_EQ("", message->GetMember());
EXPECT_EQ("", message->GetErrorName());
@@ -587,7 +587,7 @@ TEST(MessageTest, GetAndSetHeaders) {
TEST(MessageTest, SetInvalidHeaders) {
scoped_ptr<dbus::Response> message(dbus::Response::CreateEmpty());
EXPECT_EQ("", message->GetDestination());
- EXPECT_EQ(dbus::ObjectPath(""), message->GetPath());
+ EXPECT_EQ(dbus::ObjectPath(std::string()), message->GetPath());
EXPECT_EQ("", message->GetInterface());
EXPECT_EQ("", message->GetMember());
EXPECT_EQ("", message->GetErrorName());
@@ -607,7 +607,7 @@ TEST(MessageTest, SetInvalidHeaders) {
EXPECT_FALSE(message->SetSender("?!#*"));
EXPECT_EQ("", message->GetDestination());
- EXPECT_EQ(dbus::ObjectPath(""), message->GetPath());
+ EXPECT_EQ(dbus::ObjectPath(std::string()), message->GetPath());
EXPECT_EQ("", message->GetInterface());
EXPECT_EQ("", message->GetMember());
EXPECT_EQ("", message->GetErrorName());
diff --git a/dbus/string_util_unittest.cc b/dbus/string_util_unittest.cc
index 76bdfcb..99eb691 100644
--- a/dbus/string_util_unittest.cc
+++ b/dbus/string_util_unittest.cc
@@ -10,7 +10,7 @@ TEST(StringUtilTest, IsValidObjectPath) {
EXPECT_TRUE(dbus::IsValidObjectPath("/foo/bar"));
EXPECT_TRUE(dbus::IsValidObjectPath("/hoge_fuga/piyo123"));
// Empty string.
- EXPECT_FALSE(dbus::IsValidObjectPath(""));
+ EXPECT_FALSE(dbus::IsValidObjectPath(std::string()));
// Emptyr elemnt.
EXPECT_FALSE(dbus::IsValidObjectPath("//"));
EXPECT_FALSE(dbus::IsValidObjectPath("/foo//bar"));
diff --git a/dbus/values_util.cc b/dbus/values_util.cc
index 2e2d8e3..7574f39 100644
--- a/dbus/values_util.cc
+++ b/dbus/values_util.cc
@@ -79,7 +79,7 @@ std::string GetTypeSignature(const base::Value& value) {
return "a{sv}";
default:
DLOG(ERROR) << "Unexpected type " << value.GetType();
- return "";
+ return std::string();
}
}