summaryrefslogtreecommitdiffstats
path: root/sync/notifier
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 /sync/notifier
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 'sync/notifier')
-rw-r--r--sync/notifier/p2p_invalidator.cc22
-rw-r--r--sync/notifier/p2p_invalidator_unittest.cc14
-rw-r--r--sync/notifier/push_client_channel_unittest.cc2
-rw-r--r--sync/notifier/sync_invalidation_listener_unittest.cc2
-rw-r--r--sync/notifier/sync_system_resources.cc5
-rw-r--r--sync/notifier/sync_system_resources_unittest.cc5
6 files changed, 29 insertions, 21 deletions
diff --git a/sync/notifier/p2p_invalidator.cc b/sync/notifier/p2p_invalidator.cc
index dd9a34d..7825757 100644
--- a/sync/notifier/p2p_invalidator.cc
+++ b/sync/notifier/p2p_invalidator.cc
@@ -40,7 +40,7 @@ std::string P2PNotificationTargetToString(P2PNotificationTarget target) {
return kNotifyAll;
default:
NOTREACHED();
- return "";
+ return std::string();
}
}
@@ -171,8 +171,9 @@ void P2PInvalidator::UpdateRegisteredIds(InvalidationHandler* handler,
ObjectIdLessThan());
registrar_.UpdateRegisteredIds(handler, ids);
const P2PNotificationData notification_data(
- invalidator_client_id_, NOTIFY_SELF,
- ObjectIdSetToInvalidationMap(new_ids, ""));
+ invalidator_client_id_,
+ NOTIFY_SELF,
+ ObjectIdSetToInvalidationMap(new_ids, std::string()));
SendNotificationData(notification_data);
}
@@ -224,8 +225,10 @@ void P2PInvalidator::OnNotificationsEnabled() {
registrar_.UpdateInvalidatorState(INVALIDATIONS_ENABLED);
if (just_turned_on) {
const P2PNotificationData notification_data(
- invalidator_client_id_, NOTIFY_SELF,
- ObjectIdSetToInvalidationMap(registrar_.GetAllRegisteredIds(), ""));
+ invalidator_client_id_,
+ NOTIFY_SELF,
+ ObjectIdSetToInvalidationMap(registrar_.GetAllRegisteredIds(),
+ std::string()));
SendNotificationData(notification_data);
}
}
@@ -256,10 +259,11 @@ void P2PInvalidator::OnIncomingNotification(
if (!notification_data.ResetFromString(notification.data)) {
LOG(WARNING) << "Could not parse notification data from "
<< notification.data;
- notification_data =
- P2PNotificationData(
- invalidator_client_id_, NOTIFY_ALL,
- ObjectIdSetToInvalidationMap(registrar_.GetAllRegisteredIds(), ""));
+ notification_data = P2PNotificationData(
+ invalidator_client_id_,
+ NOTIFY_ALL,
+ ObjectIdSetToInvalidationMap(registrar_.GetAllRegisteredIds(),
+ std::string()));
}
if (!notification_data.IsTargeted(invalidator_client_id_)) {
DVLOG(1) << "Not a target of the notification -- "
diff --git a/sync/notifier/p2p_invalidator_unittest.cc b/sync/notifier/p2p_invalidator_unittest.cc
index 1b7aad4..6acc3d1 100644
--- a/sync/notifier/p2p_invalidator_unittest.cc
+++ b/sync/notifier/p2p_invalidator_unittest.cc
@@ -69,7 +69,7 @@ class P2PInvalidatorTestDelegate {
void TriggerOnIncomingInvalidation(
const ObjectIdInvalidationMap& invalidation_map) {
const P2PNotificationData notification_data(
- "", NOTIFY_ALL, invalidation_map);
+ std::string(), NOTIFY_ALL, invalidation_map);
notifier::Notification notification;
notification.channel = kSyncP2PNotificationChannel;
notification.data = notification_data.ToString();
@@ -160,7 +160,7 @@ TEST_F(P2PInvalidatorTest, P2PNotificationDataIsTargeted) {
// default-constructed P2PNotificationData.
TEST_F(P2PInvalidatorTest, P2PNotificationDataDefault) {
const P2PNotificationData notification_data;
- EXPECT_TRUE(notification_data.IsTargeted(""));
+ EXPECT_TRUE(notification_data.IsTargeted(std::string()));
EXPECT_FALSE(notification_data.IsTargeted("other1"));
EXPECT_FALSE(notification_data.IsTargeted("other2"));
EXPECT_TRUE(notification_data.GetIdInvalidationMap().empty());
@@ -179,7 +179,8 @@ TEST_F(P2PInvalidatorTest, P2PNotificationDataDefault) {
TEST_F(P2PInvalidatorTest, P2PNotificationDataNonDefault) {
const ObjectIdInvalidationMap& invalidation_map =
ObjectIdSetToInvalidationMap(
- ModelTypeSetToObjectIdSet(ModelTypeSet(BOOKMARKS, THEMES)), "");
+ ModelTypeSetToObjectIdSet(ModelTypeSet(BOOKMARKS, THEMES)),
+ std::string());
const P2PNotificationData notification_data(
"sender", NOTIFY_ALL, invalidation_map);
EXPECT_TRUE(notification_data.IsTargeted("sender"));
@@ -247,7 +248,8 @@ TEST_F(P2PInvalidatorTest, NotificationsBasic) {
{
const ObjectIdInvalidationMap& invalidation_map =
ObjectIdSetToInvalidationMap(
- ModelTypeSetToObjectIdSet(ModelTypeSet(THEMES, APPS)), "");
+ ModelTypeSetToObjectIdSet(ModelTypeSet(THEMES, APPS)),
+ std::string());
invalidator->SendInvalidation(invalidation_map);
}
@@ -264,8 +266,8 @@ TEST_F(P2PInvalidatorTest, SendNotificationData) {
const ModelTypeSet expected_types(THEMES);
const ObjectIdInvalidationMap& invalidation_map =
- ObjectIdSetToInvalidationMap(
- ModelTypeSetToObjectIdSet(changed_types), "");
+ ObjectIdSetToInvalidationMap(ModelTypeSetToObjectIdSet(changed_types),
+ std::string());
P2PInvalidator* const invalidator = delegate_.GetInvalidator();
notifier::FakePushClient* const push_client = delegate_.GetPushClient();
diff --git a/sync/notifier/push_client_channel_unittest.cc b/sync/notifier/push_client_channel_unittest.cc
index ffe90e7..d017e1b 100644
--- a/sync/notifier/push_client_channel_unittest.cc
+++ b/sync/notifier/push_client_channel_unittest.cc
@@ -73,7 +73,7 @@ TEST_F(PushClientChannelTest, EncodeDecode) {
TEST_F(PushClientChannelTest, EncodeDecodeNoContext) {
const notifier::Notification& notification =
PushClientChannel::EncodeMessageForTest(
- kMessage, "", kSchedulingHash);
+ kMessage, std::string(), kSchedulingHash);
std::string message;
std::string service_context = kServiceContext;
int64 scheduling_hash = kSchedulingHash + 1;
diff --git a/sync/notifier/sync_invalidation_listener_unittest.cc b/sync/notifier/sync_invalidation_listener_unittest.cc
index 8177327..dba4728 100644
--- a/sync/notifier/sync_invalidation_listener_unittest.cc
+++ b/sync/notifier/sync_invalidation_listener_unittest.cc
@@ -148,7 +148,7 @@ class FakeDelegate : public SyncInvalidationListener::Delegate {
std::string GetPayload(const ObjectId& id) const {
ObjectIdInvalidationMap::const_iterator it = invalidations_.find(id);
- return (it == invalidations_.end()) ? "" : it->second.payload;
+ return (it == invalidations_.end()) ? std::string() : it->second.payload;
}
InvalidatorState GetInvalidatorState() const {
diff --git a/sync/notifier/sync_system_resources.cc b/sync/notifier/sync_system_resources.cc
index 5328657..3fc31fc 100644
--- a/sync/notifier/sync_system_resources.cc
+++ b/sync/notifier/sync_system_resources.cc
@@ -181,14 +181,15 @@ void SyncStorage::SetSystemResources(
void SyncStorage::RunAndDeleteWriteKeyCallback(
invalidation::WriteKeyCallback* callback) {
- callback->Run(invalidation::Status(invalidation::Status::SUCCESS, ""));
+ callback->Run(
+ invalidation::Status(invalidation::Status::SUCCESS, std::string()));
delete callback;
}
void SyncStorage::RunAndDeleteReadKeyCallback(
invalidation::ReadKeyCallback* callback, const std::string& value) {
callback->Run(std::make_pair(
- invalidation::Status(invalidation::Status::SUCCESS, ""),
+ invalidation::Status(invalidation::Status::SUCCESS, std::string()),
value));
delete callback;
}
diff --git a/sync/notifier/sync_system_resources_unittest.cc b/sync/notifier/sync_system_resources_unittest.cc
index 77423b3..cb406da 100644
--- a/sync/notifier/sync_system_resources_unittest.cc
+++ b/sync/notifier/sync_system_resources_unittest.cc
@@ -168,9 +168,10 @@ TEST_F(SyncSystemResourcesTest, WriteState) {
EXPECT_CALL(mock_storage_callback, Run(_))
.WillOnce(SaveArg<0>(&results));
sync_system_resources_.storage()->WriteKey(
- "", "state", mock_storage_callback.CreateCallback());
+ std::string(), "state", mock_storage_callback.CreateCallback());
message_loop_.RunUntilIdle();
- EXPECT_EQ(invalidation::Status(invalidation::Status::SUCCESS, ""), results);
+ EXPECT_EQ(invalidation::Status(invalidation::Status::SUCCESS, std::string()),
+ results);
}
} // namespace