From e59558b78e8c6a1b0bd916a724724b638c3c91b6 Mon Sep 17 00:00:00 2001 From: "dcheng@chromium.org" Date: Tue, 9 Apr 2013 05:45:17 +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 Review URL: https://codereview.chromium.org/13145003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193020 0039d316-1c4b-4281-b951-d872f2087c98 --- jingle/notifier/base/gaia_token_pre_xmpp_auth.cc | 7 ++++--- jingle/notifier/communicator/single_login_attempt.cc | 6 +++--- jingle/notifier/communicator/single_login_attempt_unittest.cc | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'jingle/notifier') diff --git a/jingle/notifier/base/gaia_token_pre_xmpp_auth.cc b/jingle/notifier/base/gaia_token_pre_xmpp_auth.cc index 24aa6a9..f7ddf8d 100644 --- a/jingle/notifier/base/gaia_token_pre_xmpp_auth.cc +++ b/jingle/notifier/base/gaia_token_pre_xmpp_auth.cc @@ -101,9 +101,10 @@ std::string GaiaTokenPreXmppAuth::GetAuthMechanism() const { std::string GaiaTokenPreXmppAuth::ChooseBestSaslMechanism( const std::vector & mechanisms, bool encrypted) { - return (std::find(mechanisms.begin(), - mechanisms.end(), auth_mechanism_) != - mechanisms.end()) ? auth_mechanism_ : ""; + return (std::find(mechanisms.begin(), mechanisms.end(), auth_mechanism_) != + mechanisms.end()) + ? auth_mechanism_ + : std::string(); } buzz::SaslMechanism* GaiaTokenPreXmppAuth::CreateSaslMechanism( diff --git a/jingle/notifier/communicator/single_login_attempt.cc b/jingle/notifier/communicator/single_login_attempt.cc index dda0cfe..49fcdee 100644 --- a/jingle/notifier/communicator/single_login_attempt.cc +++ b/jingle/notifier/communicator/single_login_attempt.cc @@ -85,9 +85,9 @@ net::HostPortPair ParseRedirectText(const std::string& redirect_text) { void SingleLoginAttempt::OnError(buzz::XmppEngine::Error error, int subcode, const buzz::XmlElement* stream_error) { DVLOG(1) << "Error: " << error << ", subcode: " << subcode - << (stream_error ? - (", stream error: " + XmlElementToString(*stream_error)) : - ""); + << (stream_error + ? (", stream error: " + XmlElementToString(*stream_error)) + : std::string()); DCHECK_EQ(error == buzz::XmppEngine::ERROR_STREAM, stream_error != NULL); diff --git a/jingle/notifier/communicator/single_login_attempt_unittest.cc b/jingle/notifier/communicator/single_login_attempt_unittest.cc index 582b808..4d009c2 100644 --- a/jingle/notifier/communicator/single_login_attempt_unittest.cc +++ b/jingle/notifier/communicator/single_login_attempt_unittest.cc @@ -219,7 +219,7 @@ TEST_F(SingleLoginAttemptTest, RedirectInvalidPort) { // Fire an empty redirect and make sure the delegate does not get a // redirect. TEST_F(SingleLoginAttemptTest, RedirectEmpty) { - scoped_ptr redirect_error(MakeRedirectError("")); + scoped_ptr redirect_error(MakeRedirectError(std::string())); FireRedirect(redirect_error.get()); EXPECT_EQ(IDLE, fake_delegate_.state()); } @@ -227,7 +227,7 @@ TEST_F(SingleLoginAttemptTest, RedirectEmpty) { // Fire a redirect with a missing text element and make sure the // delegate does not get a redirect. TEST_F(SingleLoginAttemptTest, RedirectMissingText) { - scoped_ptr redirect_error(MakeRedirectError("")); + scoped_ptr redirect_error(MakeRedirectError(std::string())); redirect_error->RemoveChildAfter(redirect_error->FirstChild()); FireRedirect(redirect_error.get()); EXPECT_EQ(IDLE, fake_delegate_.state()); @@ -236,7 +236,7 @@ TEST_F(SingleLoginAttemptTest, RedirectMissingText) { // Fire a redirect with a missing see-other-host element and make sure // the delegate does not get a redirect. TEST_F(SingleLoginAttemptTest, RedirectMissingSeeOtherHost) { - scoped_ptr redirect_error(MakeRedirectError("")); + scoped_ptr redirect_error(MakeRedirectError(std::string())); redirect_error->RemoveChildAfter(NULL); FireRedirect(redirect_error.get()); EXPECT_EQ(IDLE, fake_delegate_.state()); -- cgit v1.1