Fix 10 ClangTidy - Performance findings in //depot/google3/third_party/quic/. These fixes are automatically created by various analysis tools, but their application in this CL has been manually triggered. See go/code-findings-fixes. * passing result of std::move() as a const reference argument; no move will actually happen (4 times) * use absl::StartsWith instead of find() == 0 * use ZeroDuration() for zero-length time intervals (5 times) PiperOrigin-RevId: 276497039 Change-Id: Ic5461dfa0fee864263437bafa7d4a137e2b44f25
diff --git a/quic/core/crypto/crypto_server_test.cc b/quic/core/crypto/crypto_server_test.cc index b869f8b..902d41e 100644 --- a/quic/core/crypto/crypto_server_test.cc +++ b/quic/core/crypto/crypto_server_test.cc
@@ -125,7 +125,7 @@ config_.GenerateConfig(rand_, &clock_, config_options_); primary_config.set_primary_time(clock_.WallNow().ToUNIXSeconds()); std::unique_ptr<CryptoHandshakeMessage> msg( - config_.AddConfig(std::move(primary_config), clock_.WallNow())); + config_.AddConfig(primary_config, clock_.WallNow())); QuicStringPiece orbit; CHECK(msg->GetStringPiece(kORBT, &orbit));
diff --git a/quic/core/crypto/quic_crypto_server_config_test.cc b/quic/core/crypto/quic_crypto_server_config_test.cc index bc9b2ef..8f9e4ba 100644 --- a/quic/core/crypto/quic_crypto_server_config_test.cc +++ b/quic/core/crypto/quic_crypto_server_config_test.cc
@@ -18,6 +18,7 @@ #include "net/third_party/quiche/src/quic/core/quic_time.h" #include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h" #include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" #include "net/third_party/quiche/src/quic/test_tools/mock_clock.h" #include "net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.h" @@ -351,7 +352,7 @@ QuicCryptoServerConfig::GenerateConfig(rand_, &clock_, options); protobuf.set_primary_time(primary_time); protobuf.set_priority(priority); - if (std::string(server_config_id).find("INVALID") == 0) { + if (QuicTextUtils::StartsWith(std::string(server_config_id), "INVALID")) { protobuf.clear_key(); has_invalid = true; }
diff --git a/quic/qbone/bonnet/icmp_reachable_test.cc b/quic/qbone/bonnet/icmp_reachable_test.cc index 303f0e2..99de19c 100644 --- a/quic/qbone/bonnet/icmp_reachable_test.cc +++ b/quic/qbone/bonnet/icmp_reachable_test.cc
@@ -118,7 +118,7 @@ }; TEST_F(IcmpReachableTest, SendsPings) { - IcmpReachable reachable(source_, destination_, absl::Seconds(0), &kernel_, + IcmpReachable reachable(source_, destination_, absl::ZeroDuration(), &kernel_, &epoll_server_, &stats_); SetFdExpectations(); @@ -140,7 +140,7 @@ } TEST_F(IcmpReachableTest, HandlesUnreachableEvents) { - IcmpReachable reachable(source_, destination_, absl::Seconds(0), &kernel_, + IcmpReachable reachable(source_, destination_, absl::ZeroDuration(), &kernel_, &epoll_server_, &stats_); SetFdExpectations(); @@ -164,7 +164,7 @@ } TEST_F(IcmpReachableTest, HandlesReachableEvents) { - IcmpReachable reachable(source_, destination_, absl::Seconds(0), &kernel_, + IcmpReachable reachable(source_, destination_, absl::ZeroDuration(), &kernel_, &epoll_server_, &stats_); SetFdExpectations(); @@ -212,7 +212,7 @@ } TEST_F(IcmpReachableTest, HandlesWriteErrors) { - IcmpReachable reachable(source_, destination_, absl::Seconds(0), &kernel_, + IcmpReachable reachable(source_, destination_, absl::ZeroDuration(), &kernel_, &epoll_server_, &stats_); SetFdExpectations(); @@ -232,7 +232,7 @@ } TEST_F(IcmpReachableTest, HandlesReadErrors) { - IcmpReachable reachable(source_, destination_, absl::Seconds(0), &kernel_, + IcmpReachable reachable(source_, destination_, absl::ZeroDuration(), &kernel_, &epoll_server_, &stats_); SetFdExpectations();
diff --git a/quic/qbone/qbone_session_test.cc b/quic/qbone/qbone_session_test.cc index 83ee087..dee951e 100644 --- a/quic/qbone/qbone_session_test.cc +++ b/quic/qbone/qbone_session_test.cc
@@ -298,7 +298,7 @@ server_crypto_config_->GenerateConfig(QuicRandom::GetInstance(), GetClock(), options); std::unique_ptr<CryptoHandshakeMessage> message( - server_crypto_config_->AddConfig(std::move(primary_config), + server_crypto_config_->AddConfig(primary_config, GetClock()->WallNow())); server_peer_ = std::make_unique<QboneServerSession>(
diff --git a/quic/test_tools/crypto_test_utils.cc b/quic/test_tools/crypto_test_utils.cc index 98d65e8..f38ea81 100644 --- a/quic/test_tools/crypto_test_utils.cc +++ b/quic/test_tools/crypto_test_utils.cc
@@ -782,7 +782,7 @@ QuicRandom::GetInstance(), clock, new_config_options); primary_config.set_primary_time(clock->WallNow().ToUNIXSeconds()); std::unique_ptr<CryptoHandshakeMessage> msg = - crypto_config->AddConfig(std::move(primary_config), clock->WallNow()); + crypto_config->AddConfig(primary_config, clock->WallNow()); QuicStringPiece orbit; CHECK(msg->GetStringPiece(kORBT, &orbit)); std::string nonce;
diff --git a/quic/test_tools/crypto_test_utils_test.cc b/quic/test_tools/crypto_test_utils_test.cc index 59a3947..6565497 100644 --- a/quic/test_tools/crypto_test_utils_test.cc +++ b/quic/test_tools/crypto_test_utils_test.cc
@@ -128,7 +128,7 @@ QuicRandom::GetInstance(), &clock, new_config_options); primary_config.set_primary_time(clock.WallNow().ToUNIXSeconds()); std::unique_ptr<CryptoHandshakeMessage> msg = - crypto_config.AddConfig(std::move(primary_config), clock.WallNow()); + crypto_config.AddConfig(primary_config, clock.WallNow()); QuicStringPiece orbit; ASSERT_TRUE(msg->GetStringPiece(kORBT, &orbit)); std::string nonce;