summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2016-07-27 20:56:10 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-07-27 20:56:10 +0000
commit437e673254a98ea036d5d229ebacc9b3763f461b (patch)
tree448927ca7b53cc8115ffa8ef74d838f5f0a5795c
parentbb780700ae3258e229edd902e7dc18fbc527880d (diff)
parentceb4eb05901b33e34423ae5bfe2b1ffeef83e128 (diff)
downloadandroid_system_tools_aidl-437e673254a98ea036d5d229ebacc9b3763f461b.tar.gz
android_system_tools_aidl-437e673254a98ea036d5d229ebacc9b3763f461b.tar.bz2
android_system_tools_aidl-437e673254a98ea036d5d229ebacc9b3763f461b.zip
Fix clang-tidy performance warnings. am: f05cc26630
am: ceb4eb0590 Change-Id: Ia5cacaf8a94fc84c11708e8820de052fc8456ee5
-rw-r--r--aidl.cpp6
-rw-r--r--aidl.h4
-rw-r--r--aidl_language.cpp2
-rw-r--r--aidl_language.h2
-rw-r--r--generate_cpp.cpp8
-rw-r--r--tests/aidl_test_client_file_descriptors.cpp4
-rw-r--r--tests/aidl_test_client_nullables.cpp2
-rw-r--r--type_cpp.h2
-rw-r--r--type_namespace.h2
9 files changed, 16 insertions, 16 deletions
diff --git a/aidl.cpp b/aidl.cpp
index 513aaee..cd778fa 100644
--- a/aidl.cpp
+++ b/aidl.cpp
@@ -330,7 +330,7 @@ bool write_cpp_dep_file(const CppOptions& options,
string generate_outputFileName(const JavaOptions& options,
const AidlInterface& interface) {
- string name = interface.GetName();
+ const string& name = interface.GetName();
string package = interface.GetPackage();
string result;
@@ -536,8 +536,8 @@ bool parse_preprocessed_file(const IoDelegate& io_delegate,
}
AidlError load_and_validate_aidl(
- const std::vector<std::string> preprocessed_files,
- const std::vector<std::string> import_paths,
+ const std::vector<std::string>& preprocessed_files,
+ const std::vector<std::string>& import_paths,
const std::string& input_file_name,
const IoDelegate& io_delegate,
TypeNamespace* types,
diff --git a/aidl.h b/aidl.h
index dffdf14..2e5b0ee 100644
--- a/aidl.h
+++ b/aidl.h
@@ -55,8 +55,8 @@ bool preprocess_aidl(const JavaOptions& options,
namespace internals {
AidlError load_and_validate_aidl(
- const std::vector<std::string> preprocessed_files,
- const std::vector<std::string> import_paths,
+ const std::vector<std::string>& preprocessed_files,
+ const std::vector<std::string>& import_paths,
const std::string& input_file_name,
const IoDelegate& io_delegate,
TypeNamespace* types,
diff --git a/aidl_language.cpp b/aidl_language.cpp
index 608c9f6..6af55f8 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -244,7 +244,7 @@ AidlQualifiedName::AidlQualifiedName(std::string term,
}
}
-void AidlQualifiedName::AddTerm(std::string term) {
+void AidlQualifiedName::AddTerm(const std::string& term) {
terms_.push_back(term);
}
diff --git a/aidl_language.h b/aidl_language.h
index 43b8a9d..e27cd10 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -279,7 +279,7 @@ class AidlQualifiedName : public AidlNode {
const std::string& GetComments() const { return comments_; }
std::string GetDotName() const { return android::base::Join(terms_, '.'); }
- void AddTerm(std::string term);
+ void AddTerm(const std::string& term);
private:
std::vector<std::string> terms_;
diff --git a/generate_cpp.cpp b/generate_cpp.cpp
index 77badc4..a8b2157 100644
--- a/generate_cpp.cpp
+++ b/generate_cpp.cpp
@@ -284,7 +284,7 @@ unique_ptr<Declaration> DefineClientTransaction(const TypeNamespace& types,
// if (_aidl_ret_status != ::android::OK) { goto error; }
for (const AidlArgument* a : method.GetInArguments()) {
const Type* type = a->GetType().GetLanguageType<Type>();
- string method = type->WriteToParcelMethod();
+ const string& method = type->WriteToParcelMethod();
string var_name = ((a->IsOut()) ? "*" : "") + a->GetName();
var_name = type->WriteCast(var_name);
@@ -334,7 +334,7 @@ unique_ptr<Declaration> DefineClientTransaction(const TypeNamespace& types,
// If the method is expected to return something, read it first by convention.
const Type* return_type = method.GetType().GetLanguageType<Type>();
if (return_type != types.VoidType()) {
- string method_call = return_type->ReadFromParcelMethod();
+ const string& method_call = return_type->ReadFromParcelMethod();
b->AddStatement(new Assignment(
kAndroidStatusVarName,
new MethodCall(StringPrintf("%s.%s", kReplyVarName,
@@ -438,7 +438,7 @@ bool HandleServerTransaction(const TypeNamespace& types,
// _aidl_ret_status = _aidl_data.ReadInt32(&in_param_name);
// if (_aidl_ret_status != ::android::OK) { break; }
const Type* type = a->GetType().GetLanguageType<Type>();
- string readMethod = type->ReadFromParcelMethod();
+ const string& readMethod = type->ReadFromParcelMethod();
b->AddStatement(new Assignment{
kAndroidStatusVarName,
@@ -485,7 +485,7 @@ bool HandleServerTransaction(const TypeNamespace& types,
// _aidl_ret_status = data.WriteInt32(out_param_name);
// if (_aidl_ret_status != ::android::OK) { break; }
const Type* type = a->GetType().GetLanguageType<Type>();
- string writeMethod = type->WriteToParcelMethod();
+ const string& writeMethod = type->WriteToParcelMethod();
b->AddStatement(new Assignment{
kAndroidStatusVarName,
diff --git a/tests/aidl_test_client_file_descriptors.cpp b/tests/aidl_test_client_file_descriptors.cpp
index afe1f54..b5913a3 100644
--- a/tests/aidl_test_client_file_descriptors.cpp
+++ b/tests/aidl_test_client_file_descriptors.cpp
@@ -50,7 +50,7 @@ namespace client {
#define FdByName(_fd) #_fd, _fd
-bool DoWrite(string name, const unique_fd& fd, const string& buf) {
+bool DoWrite(const string& name, const unique_fd& fd, const string& buf) {
int wrote;
while ((wrote = write(fd.get(), buf.data(), buf.size())) < 0 && errno == EINTR);
@@ -69,7 +69,7 @@ bool DoWrite(string name, const unique_fd& fd, const string& buf) {
return false;
}
-bool DoRead(string name, const unique_fd& fd, const string& expected) {
+bool DoRead(const string& name, const unique_fd& fd, const string& expected) {
size_t length = expected.size();
int got;
string buf;
diff --git a/tests/aidl_test_client_nullables.cpp b/tests/aidl_test_client_nullables.cpp
index e876af4..805827c 100644
--- a/tests/aidl_test_client_nullables.cpp
+++ b/tests/aidl_test_client_nullables.cpp
@@ -89,7 +89,7 @@ bool ValuesEqual<vector<unique_ptr<String16>>>(
}
template<typename T>
-bool ConfirmNullableType(const sp<ITestService>& s, string type_name,
+bool ConfirmNullableType(const sp<ITestService>& s, const string& type_name,
unique_ptr<T> in,
Status(ITestService::*func)(const unique_ptr<T>&,
unique_ptr<T>*)) {
diff --git a/type_cpp.h b/type_cpp.h
index 66b2ed5..1130839 100644
--- a/type_cpp.h
+++ b/type_cpp.h
@@ -60,7 +60,7 @@ class Type : public ValidatableType {
}
void GetHeaders(std::set<std::string>* headers) const {
- for (std::string header : headers_) {
+ for (const std::string& header : headers_) {
if (!header.empty()) {
headers->insert(header);
}
diff --git a/type_namespace.h b/type_namespace.h
index caea1fa..7defd24 100644
--- a/type_namespace.h
+++ b/type_namespace.h
@@ -272,7 +272,7 @@ bool LanguageTypeNamespace<T>::MaybeAddContainerType(
const AidlType& aidl_type) {
using android::base::Join;
- std::string type_name = aidl_type.GetName();
+ const std::string& type_name = aidl_type.GetName();
if (!IsContainerType(type_name)) {
return true;
}