diff options
author | 2022-06-08 15:28:46 +0000 | |
---|---|---|
committer | 2022-06-09 08:37:56 +0000 | |
commit | b205efd45ea29a2f21489056fbb0f0309ba992d2 (patch) | |
tree | 4aee8ca270c14d258af8769e8b18879ca4186ea2 | |
parent | 72eccf5064889f7cba5a7651642e338f9e711f8a (diff) |
Fix performance-unnecessary-value-param clang-tidy issues
Test: m tidy-art
Bug: 213953102
Change-Id: Ibe16d59559d96e0a4562ecd2af1dffa28bafc068
-rw-r--r-- | build/Android.bp | 2 | ||||
-rw-r--r-- | cmdline/token_range.h | 4 | ||||
-rw-r--r-- | cmdline/unit.h | 2 | ||||
-rw-r--r-- | compiler/utils/assembler_test.h | 2 | ||||
-rw-r--r-- | profman/profile_assistant_test.cc | 2 | ||||
-rw-r--r-- | runtime/metrics/reporter_test.cc | 4 | ||||
-rw-r--r-- | runtime/subtype_check_info.h | 2 | ||||
-rw-r--r-- | tools/jvmti-agents/chain-agents/chainagents.cc | 2 | ||||
-rw-r--r-- | tools/jvmti-agents/simple-force-redefine/forceredefine.cc | 2 | ||||
-rw-r--r-- | tools/jvmti-agents/simple-profile/simple_profile.cc | 7 |
10 files changed, 15 insertions, 14 deletions
diff --git a/build/Android.bp b/build/Android.bp index 6b1330959d..930a9c7722 100644 --- a/build/Android.bp +++ b/build/Android.bp @@ -36,6 +36,7 @@ art_clang_tidy_errors = [ "modernize-use-bool-literals", "performance-implicit-conversion-in-loop", "performance-unnecessary-copy-initialization", + "performance-unnecessary-value-param", ] art_clang_tidy_allowed = [ @@ -50,7 +51,6 @@ art_clang_tidy_allowed = [ "performance-faster-string-find", "performance-for-range-copy", "performance-noexcept-move-constructor", - "performance-unnecessary-value-param", ] art_clang_tidy_disabled = [ diff --git a/cmdline/token_range.h b/cmdline/token_range.h index e28ead92df..e917e1d6d0 100644 --- a/cmdline/token_range.h +++ b/cmdline/token_range.h @@ -81,7 +81,7 @@ struct TokenRange { {} // Non-copying constructor. Retain reference to existing list of tokens. - TokenRange(std::shared_ptr<TokenList> token_list, + TokenRange(const std::shared_ptr<TokenList>& token_list, TokenList::const_iterator it_begin, TokenList::const_iterator it_end) : token_list_(token_list), @@ -98,7 +98,7 @@ struct TokenRange { TokenRange(TokenRange&&) = default; // Non-copying constructor. Retains reference to an existing list of tokens, with offset. - explicit TokenRange(std::shared_ptr<TokenList> token_list) + explicit TokenRange(const std::shared_ptr<TokenList>& token_list) : token_list_(token_list), begin_(token_list_->begin()), end_(token_list_->end()) diff --git a/cmdline/unit.h b/cmdline/unit.h index f73981fbd3..b049d62a82 100644 --- a/cmdline/unit.h +++ b/cmdline/unit.h @@ -27,7 +27,7 @@ struct Unit { Unit() {} Unit(const Unit&) = default; ~Unit() {} - bool operator==(Unit) const { + bool operator==(const Unit&) const { return true; } }; diff --git a/compiler/utils/assembler_test.h b/compiler/utils/assembler_test.h index bb22fe5bde..5c6bf13c96 100644 --- a/compiler/utils/assembler_test.h +++ b/compiler/utils/assembler_test.h @@ -259,7 +259,7 @@ class AssemblerTest : public AssemblerTestBase { std::string (AssemblerTest::*GetName1)(const Reg1&), std::string (AssemblerTest::*GetName2)(const Reg2&), std::string (AssemblerTest::*GetName3)(const Reg3&), - std::string fmt, + const std::string& fmt, int bias) { std::string str; std::vector<int64_t> imms = CreateImmediateValuesBits(abs(imm_bits), (imm_bits > 0)); diff --git a/profman/profile_assistant_test.cc b/profman/profile_assistant_test.cc index f446c0919b..7121697e2b 100644 --- a/profman/profile_assistant_test.cc +++ b/profman/profile_assistant_test.cc @@ -267,7 +267,7 @@ class ProfileAssistantTest : public CommonRuntimeTest, public ProfileTestHelper bool CreateAndDump(const std::string& input_file_contents, std::string* output_file_contents, - std::optional<const std::string> target = std::nullopt) { + const std::optional<const std::string>& target = std::nullopt) { ScratchFile profile_file; EXPECT_TRUE(CreateProfile(input_file_contents, profile_file.GetFilename(), diff --git a/runtime/metrics/reporter_test.cc b/runtime/metrics/reporter_test.cc index 3807c77991..8117d4905e 100644 --- a/runtime/metrics/reporter_test.cc +++ b/runtime/metrics/reporter_test.cc @@ -411,7 +411,7 @@ class ReportingPeriodSpecTest : public testing::Test { const std::string& spec_str, bool startup_first, bool continuous, - std::vector<uint32_t> periods) { + const std::vector<uint32_t>& periods) { Verify(spec_str, true, startup_first, continuous, periods); } @@ -420,7 +420,7 @@ class ReportingPeriodSpecTest : public testing::Test { bool valid, bool startup_first, bool continuous, - std::vector<uint32_t> periods) { + const std::vector<uint32_t>& periods) { std::string error_msg; std::optional<ReportingPeriodSpec> spec = ReportingPeriodSpec::Parse(spec_str, &error_msg); diff --git a/runtime/subtype_check_info.h b/runtime/subtype_check_info.h index d7345579c1..05afd76a63 100644 --- a/runtime/subtype_check_info.h +++ b/runtime/subtype_check_info.h @@ -153,7 +153,7 @@ struct SubtypeCheckInfo { // Create from the depth and the bitstring+of state. // This is done for convenience to avoid passing in "depth" everywhere, // since our current state is almost always a function of depth. - static SubtypeCheckInfo Create(SubtypeCheckBits compressed_value, size_t depth) { + static SubtypeCheckInfo Create(const SubtypeCheckBits& compressed_value, size_t depth) { SubtypeCheckInfo io; io.depth_ = depth; io.bitstring_and_of_ = compressed_value; diff --git a/tools/jvmti-agents/chain-agents/chainagents.cc b/tools/jvmti-agents/chain-agents/chainagents.cc index 1242409bdf..d272fc120a 100644 --- a/tools/jvmti-agents/chain-agents/chainagents.cc +++ b/tools/jvmti-agents/chain-agents/chainagents.cc @@ -53,7 +53,7 @@ enum class StartType { OnLoad, }; -static std::pair<std::string, std::string> Split(std::string source, char delim) { +static std::pair<std::string, std::string> Split(const std::string& source, char delim) { std::string first(source.substr(0, source.find(delim))); if (source.find(delim) == std::string::npos) { return std::pair(first, ""); diff --git a/tools/jvmti-agents/simple-force-redefine/forceredefine.cc b/tools/jvmti-agents/simple-force-redefine/forceredefine.cc index 055fb8aee8..34742388cb 100644 --- a/tools/jvmti-agents/simple-force-redefine/forceredefine.cc +++ b/tools/jvmti-agents/simple-force-redefine/forceredefine.cc @@ -94,7 +94,7 @@ class JvmtiAllocator : public dex::Writer::Allocator { jvmtiEnv* jvmti_; }; -static void Transform(std::shared_ptr<ir::DexFile> ir) { +static void Transform(const std::shared_ptr<ir::DexFile>& ir) { std::unique_ptr<ir::Builder> builder; for (auto& method : ir->encoded_methods) { // Do not look into abstract/bridge/native/synthetic methods. diff --git a/tools/jvmti-agents/simple-profile/simple_profile.cc b/tools/jvmti-agents/simple-profile/simple_profile.cc index 5ead97edd8..7161142839 100644 --- a/tools/jvmti-agents/simple-profile/simple_profile.cc +++ b/tools/jvmti-agents/simple-profile/simple_profile.cc @@ -26,6 +26,7 @@ #include <sstream> #include <string> #include <unordered_map> +#include <utility> #include <vector> #include "android-base/unique_fd.h" @@ -55,7 +56,7 @@ class SimpleProfileData { SimpleProfileData( jvmtiEnv* env, std::string out_fd_name, int fd, bool dump_on_shutdown, bool dump_on_main_stop) : dump_id_(0), - out_fd_name_(out_fd_name), + out_fd_name_(std::move(out_fd_name)), out_fd_(fd), shutdown_(false), dump_on_shutdown_(dump_on_shutdown || dump_on_main_stop), @@ -79,7 +80,7 @@ class SimpleProfileData { void Shutdown(jvmtiEnv* jvmti, JNIEnv* jni); private: - void DoDump(jvmtiEnv* jvmti, JNIEnv* jni, std::unordered_map<jmethodID, uint64_t> copy); + void DoDump(jvmtiEnv* jvmti, JNIEnv* jni, const std::unordered_map<jmethodID, uint64_t>& copy); jlong dump_id_; jrawMonitorID mon_; @@ -320,7 +321,7 @@ std::ostream& operator<<(std::ostream& os, ScopedMethodInfo const& method) { void SimpleProfileData::DoDump(jvmtiEnv* jvmti, JNIEnv* jni, - std::unordered_map<jmethodID, uint64_t> copy) { + const std::unordered_map<jmethodID, uint64_t>& copy) { std::ostringstream oss; oss << "["; bool is_first = true; |