diff options
author | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-09 05:45:17 +0000 |
---|---|---|
committer | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-09 05:45:17 +0000 |
commit | e59558b78e8c6a1b0bd916a724724b638c3c91b6 (patch) | |
tree | 712268a7e9e1cd552f309d89641b2bed5ad06322 /net/tools | |
parent | 31fcd34da3797bc49160620ef8c94a38652c0587 (diff) | |
download | chromium_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 'net/tools')
-rw-r--r-- | net/tools/dump_cache/url_to_filename_encoder_unittest.cc | 22 | ||||
-rw-r--r-- | net/tools/fetch/fetch_server.cc | 3 | ||||
-rw-r--r-- | net/tools/flip_server/acceptor_thread.cc | 4 | ||||
-rw-r--r-- | net/tools/flip_server/flip_in_mem_edsm_server.cc | 26 | ||||
-rw-r--r-- | net/tools/flip_server/spdy_interface.cc | 11 | ||||
-rw-r--r-- | net/tools/flip_server/streamer_interface.cc | 8 | ||||
-rw-r--r-- | net/tools/quic/end_to_end_test.cc | 4 | ||||
-rw-r--r-- | net/tools/quic/quic_client.cc | 4 | ||||
-rw-r--r-- | net/tools/quic/test_tools/quic_test_client.cc | 2 |
9 files changed, 54 insertions, 30 deletions
diff --git a/net/tools/dump_cache/url_to_filename_encoder_unittest.cc b/net/tools/dump_cache/url_to_filename_encoder_unittest.cc index 2e09e0b..23bbc6d 100644 --- a/net/tools/dump_cache/url_to_filename_encoder_unittest.cc +++ b/net/tools/dump_cache/url_to_filename_encoder_unittest.cc @@ -57,7 +57,8 @@ class UrlToFilenameEncoderTest : public ::testing::Test { void Validate(const string& in_word, const string& gold_word) { string escaped_word, url; - UrlToFilenameEncoder::EncodeSegment("", in_word, '/', &escaped_word); + UrlToFilenameEncoder::EncodeSegment( + std::string(), in_word, '/', &escaped_word); EXPECT_EQ(gold_word, escaped_word); CheckSegmentLength(escaped_word); CheckValidChars(escaped_word, '\\'); @@ -67,7 +68,8 @@ class UrlToFilenameEncoderTest : public ::testing::Test { void ValidateAllSegmentsSmall(const string& in_word) { string escaped_word, url; - UrlToFilenameEncoder::EncodeSegment("", in_word, '/', &escaped_word); + UrlToFilenameEncoder::EncodeSegment( + std::string(), in_word, '/', &escaped_word); CheckSegmentLength(escaped_word); CheckValidChars(escaped_word, '\\'); UrlToFilenameEncoder::Decode(escaped_word, '/', &url); @@ -106,13 +108,13 @@ class UrlToFilenameEncoderTest : public ::testing::Test { void ValidateUrlOldNew(const string& url, const string& gold_old_filename, const string& gold_new_filename) { - ValidateUrl(url, "", true, gold_old_filename); - ValidateUrl(url, "", false, gold_new_filename); + ValidateUrl(url, std::string(), true, gold_old_filename); + ValidateUrl(url, std::string(), false, gold_new_filename); } void ValidateEncodeSame(const string& url1, const string& url2) { - string filename1 = UrlToFilenameEncoder::Encode(url1, "", false); - string filename2 = UrlToFilenameEncoder::Encode(url2, "", false); + string filename1 = UrlToFilenameEncoder::Encode(url1, std::string(), false); + string filename2 = UrlToFilenameEncoder::Encode(url2, std::string(), false); EXPECT_EQ(filename1, filename2); } @@ -121,7 +123,7 @@ class UrlToFilenameEncoderTest : public ::testing::Test { }; TEST_F(UrlToFilenameEncoderTest, DoesNotEscape) { - ValidateNoChange(""); + ValidateNoChange(std::string()); ValidateNoChange("abcdefg"); ValidateNoChange("abcdefghijklmnopqrstuvwxyz"); ValidateNoChange("ZYXWVUT"); @@ -193,7 +195,8 @@ TEST_F(UrlToFilenameEncoderTest, EncodeUrlCorrectly) { // From bug: Double slash preserved. ValidateUrl("http://www.foo.com/u?site=http://www.google.com/index.html", - "", false, + std::string(), + false, "www.foo.com" + dir_sep_ + "u" + escape_ + "3Fsite=http" + escape_ + "3A" + dir_sep_ + escape_ + "2Fwww.google.com" + dir_sep_ + "index.html" + escape_); @@ -326,7 +329,8 @@ TEST_F(UrlToFilenameEncoderTest, BackslashSeparator) { string long_word; string escaped_word; long_word.append(UrlToFilenameEncoder::kMaximumSubdirectoryLength + 1, 'x'); - UrlToFilenameEncoder::EncodeSegment("", long_word, '\\', &escaped_word); + UrlToFilenameEncoder::EncodeSegment( + std::string(), long_word, '\\', &escaped_word); // check that one backslash, plus the escape ",-", and the ending , got added. EXPECT_EQ(long_word.size() + 4, escaped_word.size()); diff --git a/net/tools/fetch/fetch_server.cc b/net/tools/fetch/fetch_server.cc index 830cd18..34c7c83 100644 --- a/net/tools/fetch/fetch_server.cc +++ b/net/tools/fetch/fetch_server.cc @@ -36,7 +36,8 @@ int main(int argc, char**argv) { // Do work here. MessageLoop loop; - HttpServer server("", 80); // TODO(mbelshe): make port configurable + HttpServer server(std::string(), + 80); // TODO(mbelshe): make port configurable MessageLoop::current()->Run(); if (parsed_command_line.HasSwitch("stats")) { diff --git a/net/tools/flip_server/acceptor_thread.cc b/net/tools/flip_server/acceptor_thread.cc index b16d181..ed8a3ec 100644 --- a/net/tools/flip_server/acceptor_thread.cc +++ b/net/tools/flip_server/acceptor_thread.cc @@ -105,7 +105,9 @@ void SMAcceptorThread::HandleConnection(int server_fd, NULL, &epoll_server_, server_fd, - "", "", remote_ip, + std::string(), + std::string(), + remote_ip, use_ssl_); if (server_connection->initialized()) active_server_connections_.push_back(server_connection); diff --git a/net/tools/flip_server/flip_in_mem_edsm_server.cc b/net/tools/flip_server/flip_in_mem_edsm_server.cc index 8ba1505..15fb9644 100644 --- a/net/tools/flip_server/flip_in_mem_edsm_server.cc +++ b/net/tools/flip_server/flip_in_mem_edsm_server.cc @@ -335,11 +335,16 @@ int main (int argc, char**argv) std::string value = cl.GetSwitchValueASCII("spdy-server"); std::vector<std::string> valueArgs = split(value, ','); while (valueArgs.size() < 4) - valueArgs.push_back(""); + valueArgs.push_back(std::string()); g_proxy_config.AddAcceptor(net::FLIP_HANDLER_SPDY_SERVER, - valueArgs[0], valueArgs[1], - valueArgs[2], valueArgs[3], - "", "", "", "", + valueArgs[0], + valueArgs[1], + valueArgs[2], + valueArgs[3], + std::string(), + std::string(), + std::string(), + std::string(), 0, FLAGS_accept_backlog_size, FLAGS_disable_nagle, @@ -356,11 +361,16 @@ int main (int argc, char**argv) std::string value = cl.GetSwitchValueASCII("http-server"); std::vector<std::string> valueArgs = split(value, ','); while (valueArgs.size() < 4) - valueArgs.push_back(""); + valueArgs.push_back(std::string()); g_proxy_config.AddAcceptor(net::FLIP_HANDLER_HTTP_SERVER, - valueArgs[0], valueArgs[1], - valueArgs[2], valueArgs[3], - "", "", "", "", + valueArgs[0], + valueArgs[1], + valueArgs[2], + valueArgs[3], + std::string(), + std::string(), + std::string(), + std::string(), 0, FLAGS_accept_backlog_size, FLAGS_disable_nagle, diff --git a/net/tools/flip_server/spdy_interface.cc b/net/tools/flip_server/spdy_interface.cc index 1c34e79..649e99e 100644 --- a/net/tools/flip_server/spdy_interface.cc +++ b/net/tools/flip_server/spdy_interface.cc @@ -112,9 +112,14 @@ SMInterface* SpdySM::FindOrMakeNewSMConnectionInterface( } sm_http_interface->InitSMInterface(this, server_idx); - sm_http_interface->InitSMConnection(NULL, sm_http_interface, - epoll_server_, -1, - server_ip, server_port, "", false); + sm_http_interface->InitSMConnection(NULL, + sm_http_interface, + epoll_server_, + -1, + server_ip, + server_port, + std::string(), + false); return sm_http_interface; } diff --git a/net/tools/flip_server/streamer_interface.cc b/net/tools/flip_server/streamer_interface.cc index 9e6e6c8..b1612e7 100644 --- a/net/tools/flip_server/streamer_interface.cc +++ b/net/tools/flip_server/streamer_interface.cc @@ -131,11 +131,13 @@ int StreamerSM::PostAcceptHook() { } // The Streamer interface is used to stream HTTPS connections, so we // will always use the https_server_ip/port here. - sm_other_interface_->InitSMConnection(NULL, sm_other_interface_, - epoll_server_, -1, + sm_other_interface_->InitSMConnection(NULL, + sm_other_interface_, + epoll_server_, + -1, acceptor_->https_server_ip_, acceptor_->https_server_port_, - "", + std::string(), false); return 1; diff --git a/net/tools/quic/end_to_end_test.cc b/net/tools/quic/end_to_end_test.cc index e98c4ea..cb14db8 100644 --- a/net/tools/quic/end_to_end_test.cc +++ b/net/tools/quic/end_to_end_test.cc @@ -234,7 +234,7 @@ TEST_F(EndToEndTest, SeparateFinPacket) { client_->SendMessage(request); - client_->SendData("", true); + client_->SendData(std::string(), true); client_->WaitForResponse(); EXPECT_EQ(kFooResponseBody, client_->response_body()); @@ -243,7 +243,7 @@ TEST_F(EndToEndTest, SeparateFinPacket) { request.AddBody("foo", true); client_->SendMessage(request); - client_->SendData("", true); + client_->SendData(std::string(), true); client_->WaitForResponse(); EXPECT_EQ(kFooResponseBody, client_->response_body()); EXPECT_EQ(200ul, client_->response_headers()->parsed_response_code()); diff --git a/net/tools/quic/quic_client.cc b/net/tools/quic/quic_client.cc index 4a61ab4..8acb85a 100644 --- a/net/tools/quic/quic_client.cc +++ b/net/tools/quic/quic_client.cc @@ -43,8 +43,8 @@ QuicClient::QuicClient(IPEndPoint server_address, QuicClient::~QuicClient() { if (connected()) { - session()->connection()->SendConnectionClosePacket( - QUIC_PEER_GOING_AWAY, ""); + session()->connection() + ->SendConnectionClosePacket(QUIC_PEER_GOING_AWAY, std::string()); } } diff --git a/net/tools/quic/test_tools/quic_test_client.cc b/net/tools/quic/test_tools/quic_test_client.cc index 53bc057..843af2f 100644 --- a/net/tools/quic/test_tools/quic_test_client.cc +++ b/net/tools/quic/test_tools/quic_test_client.cc @@ -85,7 +85,7 @@ string QuicTestClient::SendCustomSynchronousRequest( string QuicTestClient::SendSynchronousRequest(const string& uri) { if (SendRequest(uri) == 0) { DLOG(ERROR) << "Failed to the request for uri:" << uri; - return ""; + return std::string(); } WaitForResponse(); return response_; |