Fix some performance-unnecessary-value-param tidy and performance-for-range warnings.
art/profman/profile_assistant_test.cc:119:54: error: the const qualified parameter 'hot_methods' is copied for each invocation; consider making it a reference [performance-unnecessary-value-param,-warnings-as-errors]
const std::vector<uint32_t> hot_methods,
^
&
art/profman/profile_assistant_test.cc:120:54: error: the const qualified parameter 'startup_methods' is copied for each invocation; consider making it a reference [performance-unnecessary-value-param,-warnings-as-errors]
const std::vector<uint32_t> startup_methods,
^
&
art/profman/profile_assistant_test.cc:121:54: error: the const qualified parameter 'post_startup_methods' is copied for each invocation; consider making it a reference [performance-unnecessary-value-param,-warnings-as-errors]
const std::vector<uint32_t> post_startup_methods,
^
&
art/runtime/subtype_check_info_test.cc:134:56: error: the parameter 'sc' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param,-warnings-as-errors]
static SubtypeCheckInfo CopyCleared(SubtypeCheckInfo sc) {
~~~~~~~~~~~~~~~~ ^
const &
art/runtime/class_linker.cc:6451:62: error: the parameter 'to_process' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param,-warnings-as-errors]
std::vector<ObjPtr<mirror::Class>> to_process)
~~~ ^
const &
art/runtime/trace.cc:1127:13: error: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy,-warnings-as-errors]
for (auto it : exited_threads_) {
~~~~ ^
const &
art/runtime/oat_file_manager.cc:154:41: error: the parameter 'spaces' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param,-warnings-as-errors]
std::vector<gc::space::ImageSpace*> spaces) {
~~~ ^
const &
art/test/004-JniTest/jni_test.cc:707:72: error: the parameter 'methods' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param,-warnings-as-errors]
void TestCalls(const char* declaring_class, std::vector<const char*> methods) {
~~~ ^
const &
art/compiler/optimizing/optimizing_compiler.cc:1409:89: error: the parameter 'info' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param,-warnings-as-errors]
void OptimizingCompiler::GenerateJitDebugInfo(ArtMethod* method, debug::MethodDebugInfo info) {
~~~~~ ^
const &
Bug: http://b/32619234
Bug: http://b/110779387
Test: Build using WITH_TIDY=1
Change-Id: I911d838b8c26ddab3d6a64024f3220000f078cba
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index 9ae025b..3a550ef 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -399,7 +399,8 @@
PassObserver* pass_observer,
VariableSizedHandleScope* handles) const;
- void GenerateJitDebugInfo(ArtMethod* method, debug::MethodDebugInfo method_debug_info)
+ void GenerateJitDebugInfo(ArtMethod* method,
+ const debug::MethodDebugInfo& method_debug_info)
REQUIRES_SHARED(Locks::mutator_lock_);
std::unique_ptr<OptimizingCompilerStats> compilation_stats_;
@@ -1406,7 +1407,8 @@
return true;
}
-void OptimizingCompiler::GenerateJitDebugInfo(ArtMethod* method, debug::MethodDebugInfo info) {
+void OptimizingCompiler::GenerateJitDebugInfo(
+ ArtMethod* method, const debug::MethodDebugInfo& info) {
const CompilerOptions& compiler_options = GetCompilerDriver()->GetCompilerOptions();
DCHECK(compiler_options.GenerateAnyDebugInfo());
diff --git a/profman/profile_assistant_test.cc b/profman/profile_assistant_test.cc
index 286b686..f9707d3 100644
--- a/profman/profile_assistant_test.cc
+++ b/profman/profile_assistant_test.cc
@@ -116,9 +116,9 @@
void SetupBasicProfile(const std::string& id,
uint32_t checksum,
uint16_t number_of_methods,
- const std::vector<uint32_t> hot_methods,
- const std::vector<uint32_t> startup_methods,
- const std::vector<uint32_t> post_startup_methods,
+ const std::vector<uint32_t>& hot_methods,
+ const std::vector<uint32_t>& startup_methods,
+ const std::vector<uint32_t>& post_startup_methods,
const ScratchFile& profile,
ProfileCompilationInfo* info) {
std::string dex_location = "location1" + id;
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index befeea4..14b44dd 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -6448,7 +6448,7 @@
// iftable must be large enough to hold all interfaces without changing its size.
static size_t FillIfTable(ObjPtr<mirror::IfTable> iftable,
size_t super_ifcount,
- std::vector<ObjPtr<mirror::Class>> to_process)
+ const std::vector<ObjPtr<mirror::Class>>& to_process)
REQUIRES(Roles::uninterruptible_)
REQUIRES_SHARED(Locks::mutator_lock_) {
// This is the set of all class's already in the iftable. Used to make checking if a class has
diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc
index 1f0b265..92d2d44 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -151,7 +151,7 @@
}
std::vector<const OatFile*> OatFileManager::RegisterImageOatFiles(
- std::vector<gc::space::ImageSpace*> spaces) {
+ const std::vector<gc::space::ImageSpace*>& spaces) {
std::vector<const OatFile*> oat_files;
for (gc::space::ImageSpace* space : spaces) {
oat_files.push_back(RegisterOatFile(space->ReleaseOatFile()));
diff --git a/runtime/oat_file_manager.h b/runtime/oat_file_manager.h
index 4132b25..7d96a7a 100644
--- a/runtime/oat_file_manager.h
+++ b/runtime/oat_file_manager.h
@@ -73,7 +73,8 @@
// Returns the oat files for the images, registers the oat files.
// Takes ownership of the imagespace's underlying oat files.
- std::vector<const OatFile*> RegisterImageOatFiles(std::vector<gc::space::ImageSpace*> spaces)
+ std::vector<const OatFile*> RegisterImageOatFiles(
+ const std::vector<gc::space::ImageSpace*>& spaces)
REQUIRES(!Locks::oat_file_manager_lock_);
// Finds or creates the oat file holding dex_location. Then loads and returns
diff --git a/runtime/subtype_check_info_test.cc b/runtime/subtype_check_info_test.cc
index 5323093..9bd135e 100644
--- a/runtime/subtype_check_info_test.cc
+++ b/runtime/subtype_check_info_test.cc
@@ -131,7 +131,7 @@
// Create an SubtypeCheckInfo with the same depth, but with everything else reset.
// Returns: SubtypeCheckInfo in the Uninitialized state.
- static SubtypeCheckInfo CopyCleared(SubtypeCheckInfo sc) {
+ static SubtypeCheckInfo CopyCleared(const SubtypeCheckInfo& sc) {
SubtypeCheckInfo cleared_copy{};
cleared_copy.depth_ = sc.depth_;
DCHECK_EQ(SubtypeCheckInfo::kUninitialized, cleared_copy.GetState());
diff --git a/runtime/trace.cc b/runtime/trace.cc
index 7e48bae..0e8d318 100644
--- a/runtime/trace.cc
+++ b/runtime/trace.cc
@@ -1124,7 +1124,7 @@
void Trace::DumpThreadList(std::ostream& os) {
Thread* self = Thread::Current();
- for (auto it : exited_threads_) {
+ for (const auto& it : exited_threads_) {
os << it.first << "\t" << it.second << "\n";
}
Locks::thread_list_lock_->AssertNotHeld(self);
diff --git a/test/004-JniTest/jni_test.cc b/test/004-JniTest/jni_test.cc
index 33a8f5b..c4eb75a 100644
--- a/test/004-JniTest/jni_test.cc
+++ b/test/004-JniTest/jni_test.cc
@@ -704,7 +704,7 @@
}
private:
- void TestCalls(const char* declaring_class, std::vector<const char*> methods) {
+ void TestCalls(const char* declaring_class, const std::vector<const char*>& methods) {
jmethodID new_method = env_->GetMethodID(concrete_class_, "<init>", "()V");
jobject obj = env_->NewObject(concrete_class_, new_method);
CHECK(!env_->ExceptionCheck());