aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/util
diff options
context:
space:
mode:
authorGravatar Noah Eisen <ncteisen@google.com>2018-06-07 22:17:14 -0700
committerGravatar ncteisen <ncteisen@gmail.com>2018-06-14 14:58:09 -0400
commit58e0cbf9fb67186ee67be5bb71aba36e9cfebe7f (patch)
tree36a6e9fc3beb37ab4030d50375bebf7e6673c1a1 /test/cpp/util
parent33b77eee7890b7e8a00b256eb501d476feae09db (diff)
Enable the performance-* clang-tidy checks
Diffstat (limited to 'test/cpp/util')
-rw-r--r--test/cpp/util/byte_buffer_test.cc2
-rw-r--r--test/cpp/util/cli_call.cc5
-rw-r--r--test/cpp/util/cli_call.h3
-rw-r--r--test/cpp/util/proto_file_parser.cc2
-rw-r--r--test/cpp/util/proto_file_parser.h2
-rw-r--r--test/cpp/util/proto_reflection_descriptor_database.cc14
-rw-r--r--test/cpp/util/proto_reflection_descriptor_database.h2
-rw-r--r--test/cpp/util/string_ref_test.cc2
8 files changed, 17 insertions, 15 deletions
diff --git a/test/cpp/util/byte_buffer_test.cc b/test/cpp/util/byte_buffer_test.cc
index b48a53eed1..9bffbf7ac1 100644
--- a/test/cpp/util/byte_buffer_test.cc
+++ b/test/cpp/util/byte_buffer_test.cc
@@ -41,7 +41,7 @@ class ByteBufferTest : public ::testing::Test {};
TEST_F(ByteBufferTest, CopyCtor) {
ByteBuffer buffer1;
EXPECT_FALSE(buffer1.Valid());
- ByteBuffer buffer2 = buffer1;
+ const ByteBuffer& buffer2 = buffer1;
EXPECT_FALSE(buffer2.Valid());
}
diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc
index a3992ab278..c258bde908 100644
--- a/test/cpp/util/cli_call.cc
+++ b/test/cpp/util/cli_call.cc
@@ -19,6 +19,7 @@
#include "test/cpp/util/cli_call.h"
#include <iostream>
+#include <utility>
#include <grpc/grpc.h>
#include <grpc/slice.h>
@@ -39,7 +40,7 @@ Status CliCall::Call(std::shared_ptr<grpc::Channel> channel,
const OutgoingMetadataContainer& metadata,
IncomingMetadataContainer* server_initial_metadata,
IncomingMetadataContainer* server_trailing_metadata) {
- CliCall call(channel, method, metadata);
+ CliCall call(std::move(channel), method, metadata);
call.Write(request);
call.WritesDone();
if (!call.Read(response, server_initial_metadata)) {
@@ -48,7 +49,7 @@ Status CliCall::Call(std::shared_ptr<grpc::Channel> channel,
return call.Finish(server_trailing_metadata);
}
-CliCall::CliCall(std::shared_ptr<grpc::Channel> channel,
+CliCall::CliCall(const std::shared_ptr<grpc::Channel>& channel,
const grpc::string& method,
const OutgoingMetadataContainer& metadata)
: stub_(new grpc::GenericStub(channel)) {
diff --git a/test/cpp/util/cli_call.h b/test/cpp/util/cli_call.h
index 51ffafd29f..3f279095a4 100644
--- a/test/cpp/util/cli_call.h
+++ b/test/cpp/util/cli_call.h
@@ -42,7 +42,8 @@ class CliCall final {
typedef std::multimap<grpc::string_ref, grpc::string_ref>
IncomingMetadataContainer;
- CliCall(std::shared_ptr<grpc::Channel> channel, const grpc::string& method,
+ CliCall(const std::shared_ptr<grpc::Channel>& channel,
+ const grpc::string& method,
const OutgoingMetadataContainer& metadata);
~CliCall();
diff --git a/test/cpp/util/proto_file_parser.cc b/test/cpp/util/proto_file_parser.cc
index 3fc96f38ae..a530ed1ffc 100644
--- a/test/cpp/util/proto_file_parser.cc
+++ b/test/cpp/util/proto_file_parser.cc
@@ -63,7 +63,7 @@ class ErrorPrinter : public protobuf::compiler::MultiFileErrorCollector {
ProtoFileParser* parser_; // not owned
};
-ProtoFileParser::ProtoFileParser(std::shared_ptr<grpc::Channel> channel,
+ProtoFileParser::ProtoFileParser(const std::shared_ptr<grpc::Channel>& channel,
const grpc::string& proto_path,
const grpc::string& protofiles)
: has_error_(false),
diff --git a/test/cpp/util/proto_file_parser.h b/test/cpp/util/proto_file_parser.h
index 2236b59451..eb1d793c2b 100644
--- a/test/cpp/util/proto_file_parser.h
+++ b/test/cpp/util/proto_file_parser.h
@@ -36,7 +36,7 @@ class ProtoFileParser {
// The parser will search proto files using the server reflection service
// provided on the given channel. The given protofiles in a source tree rooted
// from proto_path will also be searched.
- ProtoFileParser(std::shared_ptr<grpc::Channel> channel,
+ ProtoFileParser(const std::shared_ptr<grpc::Channel>& channel,
const grpc::string& proto_path,
const grpc::string& protofiles);
diff --git a/test/cpp/util/proto_reflection_descriptor_database.cc b/test/cpp/util/proto_reflection_descriptor_database.cc
index 0adbf20ce6..119272ca42 100644
--- a/test/cpp/util/proto_reflection_descriptor_database.cc
+++ b/test/cpp/util/proto_reflection_descriptor_database.cc
@@ -35,7 +35,7 @@ ProtoReflectionDescriptorDatabase::ProtoReflectionDescriptorDatabase(
: stub_(std::move(stub)) {}
ProtoReflectionDescriptorDatabase::ProtoReflectionDescriptorDatabase(
- std::shared_ptr<grpc::Channel> channel)
+ const std::shared_ptr<grpc::Channel>& channel)
: stub_(ServerReflection::NewStub(channel)) {}
ProtoReflectionDescriptorDatabase::~ProtoReflectionDescriptorDatabase() {
@@ -79,7 +79,7 @@ bool ProtoReflectionDescriptorDatabase::FindFileByName(
AddFileFromResponse(response.file_descriptor_response());
} else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
- const ErrorResponse error = response.error_response();
+ const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) {
gpr_log(GPR_INFO, "NOT_FOUND from server for FindFileByName(%s)",
filename.c_str());
@@ -126,7 +126,7 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingSymbol(
AddFileFromResponse(response.file_descriptor_response());
} else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
- const ErrorResponse error = response.error_response();
+ const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) {
missing_symbols_.insert(symbol_name);
gpr_log(GPR_INFO,
@@ -182,7 +182,7 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingExtension(
AddFileFromResponse(response.file_descriptor_response());
} else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
- const ErrorResponse error = response.error_response();
+ const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) {
if (missing_extensions_.find(containing_type) ==
missing_extensions_.end()) {
@@ -238,7 +238,7 @@ bool ProtoReflectionDescriptorDatabase::FindAllExtensionNumbers(
return true;
} else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
- const ErrorResponse error = response.error_response();
+ const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) {
gpr_log(GPR_INFO, "NOT_FOUND from server for FindAllExtensionNumbers(%s)",
extendee_type.c_str());
@@ -265,14 +265,14 @@ bool ProtoReflectionDescriptorDatabase::GetServices(
if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kListServicesResponse) {
- const ListServiceResponse ls_response = response.list_services_response();
+ const ListServiceResponse& ls_response = response.list_services_response();
for (int i = 0; i < ls_response.service_size(); ++i) {
(*output).push_back(ls_response.service(i).name());
}
return true;
} else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
- const ErrorResponse error = response.error_response();
+ const ErrorResponse& error = response.error_response();
gpr_log(GPR_INFO,
"Error on GetServices()\n\tError code: %d\n"
"\tError Message: %s",
diff --git a/test/cpp/util/proto_reflection_descriptor_database.h b/test/cpp/util/proto_reflection_descriptor_database.h
index e4cf2f207e..46190b3217 100644
--- a/test/cpp/util/proto_reflection_descriptor_database.h
+++ b/test/cpp/util/proto_reflection_descriptor_database.h
@@ -38,7 +38,7 @@ class ProtoReflectionDescriptorDatabase : public protobuf::DescriptorDatabase {
std::unique_ptr<reflection::v1alpha::ServerReflection::Stub> stub);
explicit ProtoReflectionDescriptorDatabase(
- std::shared_ptr<grpc::Channel> channel);
+ const std::shared_ptr<grpc::Channel>& channel);
virtual ~ProtoReflectionDescriptorDatabase();
diff --git a/test/cpp/util/string_ref_test.cc b/test/cpp/util/string_ref_test.cc
index 8f7986e64e..031ec33241 100644
--- a/test/cpp/util/string_ref_test.cc
+++ b/test/cpp/util/string_ref_test.cc
@@ -60,7 +60,7 @@ TEST_F(StringRefTest, FromString) {
TEST_F(StringRefTest, CopyConstructor) {
string_ref s1(kTestString);
;
- string_ref s2(s1);
+ const string_ref& s2(s1);
EXPECT_EQ(s1.length(), s2.length());
EXPECT_EQ(s1.data(), s2.data());
}