From 007b3f812fc9c989fb99d4a668d8bd9c7807ad81 Mon Sep 17 00:00:00 2001 From: "dcheng@chromium.org" <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> Date: Tue, 9 Apr 2013 08:46:45 +0000 Subject: 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 --- remoting/jingle_glue/iq_sender_unittest.cc | 18 +++++++++--------- remoting/jingle_glue/xmpp_signal_strategy.cc | 9 +++++---- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'remoting/jingle_glue') diff --git a/remoting/jingle_glue/iq_sender_unittest.cc b/remoting/jingle_glue/iq_sender_unittest.cc index b09f114..2876735 100644 --- a/remoting/jingle_glue/iq_sender_unittest.cc +++ b/remoting/jingle_glue/iq_sender_unittest.cc @@ -91,9 +91,9 @@ TEST_F(IqSenderTest, SendIq) { }); scoped_ptr<XmlElement> response(new XmlElement(buzz::QN_IQ)); - response->AddAttr(QName("", "type"), "result"); - response->AddAttr(QName("", "id"), kStanzaId); - response->AddAttr(QName("", "from"), kTo); + response->AddAttr(QName(std::string(), "type"), "result"); + response->AddAttr(QName(std::string(), "id"), kStanzaId); + response->AddAttr(QName(std::string(), "from"), kTo); XmlElement* result = new XmlElement( QName("test:namespace", "response-body")); @@ -123,9 +123,9 @@ TEST_F(IqSenderTest, InvalidFrom) { }); scoped_ptr<XmlElement> response(new XmlElement(buzz::QN_IQ)); - response->AddAttr(QName("", "type"), "result"); - response->AddAttr(QName("", "id"), kStanzaId); - response->AddAttr(QName("", "from"), "different_user@domain.com"); + response->AddAttr(QName(std::string(), "type"), "result"); + response->AddAttr(QName(std::string(), "id"), kStanzaId); + response->AddAttr(QName(std::string(), "from"), "different_user@domain.com"); XmlElement* result = new XmlElement( QName("test:namespace", "response-body")); @@ -143,9 +143,9 @@ TEST_F(IqSenderTest, IdMatchingHack) { }); scoped_ptr<XmlElement> response(new XmlElement(buzz::QN_IQ)); - response->AddAttr(QName("", "type"), "result"); - response->AddAttr(QName("", "id"), "DIFFERENT_ID"); - response->AddAttr(QName("", "from"), kTo); + response->AddAttr(QName(std::string(), "type"), "result"); + response->AddAttr(QName(std::string(), "id"), "DIFFERENT_ID"); + response->AddAttr(QName(std::string(), "from"), kTo); XmlElement* result = new XmlElement( QName("test:namespace", "response-body")); diff --git a/remoting/jingle_glue/xmpp_signal_strategy.cc b/remoting/jingle_glue/xmpp_signal_strategy.cc index 51bbade..88fc9f3 100644 --- a/remoting/jingle_glue/xmpp_signal_strategy.cc +++ b/remoting/jingle_glue/xmpp_signal_strategy.cc @@ -91,9 +91,10 @@ void XmppSignalStrategy::Connect() { task_runner_.reset(new jingle_glue::TaskPump()); xmpp_client_ = new buzz::XmppClient(task_runner_.get()); - xmpp_client_->Connect(settings, "", socket, CreatePreXmppAuth(settings)); - xmpp_client_->SignalStateChange.connect( - this, &XmppSignalStrategy::OnConnectionStateChanged); + xmpp_client_->Connect( + settings, std::string(), socket, CreatePreXmppAuth(settings)); + xmpp_client_->SignalStateChange + .connect(this, &XmppSignalStrategy::OnConnectionStateChanged); xmpp_client_->engine()->AddStanzaHandler(this, buzz::XmppEngine::HL_TYPE); xmpp_client_->Start(); @@ -156,7 +157,7 @@ std::string XmppSignalStrategy::GetNextId() { if (!xmpp_client_) { // If the connection has been terminated then it doesn't matter // what Id we return. - return ""; + return std::string(); } return xmpp_client_->NextId(); } -- cgit v1.1