summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build/Android.bp1
-rw-r--r--cmdline/detail/cmdline_parse_argument_detail.h1
-rw-r--r--dex2oat/dex2oat_test.cc1
-rw-r--r--dex2oat/verifier_deps_test.cc1
-rw-r--r--imgdiag/imgdiag.cc2
-rw-r--r--libartbase/base/common_art_test.cc1
-rw-r--r--libprofile/profile/profile_boot_info_test.cc2
-rw-r--r--runtime/exec_utils.cc1
-rw-r--r--runtime/jit/profiling_info_test.cc1
-rw-r--r--test/2005-pause-all-redefine-multithreaded/pause-all.cc2
-rw-r--r--test/913-heaps/heaps.cc1
-rw-r--r--test/ti-agent/redefinition_helper.cc1
-rw-r--r--test/ti-agent/suspension_helper.cc1
-rw-r--r--tools/dexanalyze/dexanalyze_experiments.cc1
14 files changed, 16 insertions, 1 deletions
diff --git a/build/Android.bp b/build/Android.bp
index c7fc420b5d..49a436377c 100644
--- a/build/Android.bp
+++ b/build/Android.bp
@@ -42,6 +42,7 @@ art_clang_tidy_errors = [
"performance-faster-string-find",
"performance-for-range-copy",
"performance-implicit-conversion-in-loop",
+ "performance-inefficient-vector-operation",
"performance-no-automatic-move",
"performance-noexcept-move-constructor",
"performance-unnecessary-copy-initialization",
diff --git a/cmdline/detail/cmdline_parse_argument_detail.h b/cmdline/detail/cmdline_parse_argument_detail.h
index 936d290ab6..c47efe1565 100644
--- a/cmdline/detail/cmdline_parse_argument_detail.h
+++ b/cmdline/detail/cmdline_parse_argument_detail.h
@@ -485,6 +485,7 @@ struct CmdlineParseArgument : CmdlineParseArgumentAny {
// Error case: Fail, telling the user what the allowed values were.
std::vector<std::string> allowed_values;
+ allowed_values.reserve(argument_info_.names_.size());
for (auto&& arg_name : argument_info_.names_) {
allowed_values.push_back(arg_name);
}
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index 9ee532a4e3..0099ba3b74 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -74,6 +74,7 @@ class Dex2oatTest : public Dex2oatEnvironmentTest {
bool use_fd = false) {
std::unique_ptr<File> oat_file;
std::vector<std::string> args;
+ args.reserve(dex_locations.size() + extra_args.size() + 6);
// Add dex file args.
for (const std::string& dex_location : dex_locations) {
args.push_back("--dex-file=" + dex_location);
diff --git a/dex2oat/verifier_deps_test.cc b/dex2oat/verifier_deps_test.cc
index 6a2deba1d3..00593f5708 100644
--- a/dex2oat/verifier_deps_test.cc
+++ b/dex2oat/verifier_deps_test.cc
@@ -502,6 +502,7 @@ TEST_F(VerifierDepsTest, EncodeDecodeMulti) {
std::vector<std::unique_ptr<const DexFile>> first_dex_files = OpenTestDexFiles("VerifierDeps");
std::vector<std::unique_ptr<const DexFile>> second_dex_files = OpenTestDexFiles("MultiDex");
std::vector<const DexFile*> dex_files;
+ dex_files.reserve(first_dex_files.size() + second_dex_files.size());
for (auto& dex_file : first_dex_files) {
dex_files.push_back(dex_file.get());
}
diff --git a/imgdiag/imgdiag.cc b/imgdiag/imgdiag.cc
index ed2ff727fe..e3310e97f3 100644
--- a/imgdiag/imgdiag.cc
+++ b/imgdiag/imgdiag.cc
@@ -169,7 +169,7 @@ static std::vector<std::pair<V, K>> SortByValueDesc(
// Store value->key so that we can use the default sort from pair which
// sorts by value first and then key
std::vector<std::pair<V, K>> value_key_vector;
-
+ value_key_vector.reserve(map.size());
for (const auto& kv_pair : map) {
value_key_vector.push_back(std::make_pair(value_mapper(kv_pair.second), kv_pair.first));
}
diff --git a/libartbase/base/common_art_test.cc b/libartbase/base/common_art_test.cc
index c839216854..c921f2ebf1 100644
--- a/libartbase/base/common_art_test.cc
+++ b/libartbase/base/common_art_test.cc
@@ -610,6 +610,7 @@ CommonArtTestImpl::ForkAndExecResult CommonArtTestImpl::ForkAndExec(
result.stage = ForkAndExecResult::kLink;
std::vector<const char*> c_args;
+ c_args.reserve(argv.size() + 1);
for (const std::string& str : argv) {
c_args.push_back(str.c_str());
}
diff --git a/libprofile/profile/profile_boot_info_test.cc b/libprofile/profile/profile_boot_info_test.cc
index 9939f0aafb..3c5829c050 100644
--- a/libprofile/profile/profile_boot_info_test.cc
+++ b/libprofile/profile/profile_boot_info_test.cc
@@ -66,6 +66,7 @@ TEST_F(ProfileBootInfoTest, ManyDexFiles) {
ScratchFile profile;
std::vector<std::unique_ptr<const DexFile>> dex_files = OpenTestDexFiles("MultiDex");
std::vector<const DexFile*> dex_files2;
+ dex_files2.reserve(dex_files.size());
for (const std::unique_ptr<const DexFile>& file : dex_files) {
dex_files2.push_back(file.get());
}
@@ -104,6 +105,7 @@ TEST_F(ProfileBootInfoTest, LoadWrongDexFile) {
ProfileBootInfo loaded_info;
std::vector<std::unique_ptr<const DexFile>> dex_files = OpenTestDexFiles("MultiDex");
std::vector<const DexFile*> dex_files2;
+ dex_files2.reserve(dex_files.size());
for (const std::unique_ptr<const DexFile>& file : dex_files) {
dex_files2.push_back(file.get());
}
diff --git a/runtime/exec_utils.cc b/runtime/exec_utils.cc
index dd389f8c97..1021429460 100644
--- a/runtime/exec_utils.cc
+++ b/runtime/exec_utils.cc
@@ -68,6 +68,7 @@ pid_t ExecWithoutWait(const std::vector<std::string>& arg_vector, std::string* e
// Convert the args to char pointers.
const char* program = arg_vector[0].c_str();
std::vector<char*> args;
+ args.reserve(arg_vector.size() + 1);
for (const auto& arg : arg_vector) {
args.push_back(const_cast<char*>(arg.c_str()));
}
diff --git a/runtime/jit/profiling_info_test.cc b/runtime/jit/profiling_info_test.cc
index ce0a30fd9f..0bd21aad96 100644
--- a/runtime/jit/profiling_info_test.cc
+++ b/runtime/jit/profiling_info_test.cc
@@ -72,6 +72,7 @@ class ProfileCompilationInfoTest : public CommonRuntimeTest {
Hotness::Flag flags) {
ProfileCompilationInfo info;
std::vector<ProfileMethodInfo> profile_methods;
+ profile_methods.reserve(methods.size());
ScopedObjectAccess soa(Thread::Current());
for (ArtMethod* method : methods) {
profile_methods.emplace_back(
diff --git a/test/2005-pause-all-redefine-multithreaded/pause-all.cc b/test/2005-pause-all-redefine-multithreaded/pause-all.cc
index 9928411f90..37d6c4d045 100644
--- a/test/2005-pause-all-redefine-multithreaded/pause-all.cc
+++ b/test/2005-pause-all-redefine-multithreaded/pause-all.cc
@@ -41,10 +41,12 @@ Java_art_Test2005_UpdateFieldValuesAndResumeThreads(JNIEnv* env,
jobjectArray new_fields,
jstring default_val) {
std::vector<jthread> threads;
+ threads.reserve(env->GetArrayLength(threads_arr));
for (jint i = 0; i < env->GetArrayLength(threads_arr); i++) {
threads.push_back(env->GetObjectArrayElement(threads_arr, i));
}
std::vector<jfieldID> fields;
+ fields.reserve(env->GetArrayLength(new_fields));
for (jint i = 0; i < env->GetArrayLength(new_fields); i++) {
fields.push_back(env->FromReflectedField(env->GetObjectArrayElement(new_fields, i)));
}
diff --git a/test/913-heaps/heaps.cc b/test/913-heaps/heaps.cc
index 311b029a9b..671cff8a31 100644
--- a/test/913-heaps/heaps.cc
+++ b/test/913-heaps/heaps.cc
@@ -266,6 +266,7 @@ extern "C" JNIEXPORT jobjectArray JNICALL Java_art_Test913_followReferences(
std::vector<std::string> GetLines() const {
std::vector<std::string> ret;
+ ret.reserve(lines_.size());
for (const std::unique_ptr<Elem>& e : lines_) {
ret.push_back(e->Print());
}
diff --git a/test/ti-agent/redefinition_helper.cc b/test/ti-agent/redefinition_helper.cc
index 0baa9fe547..706531ef31 100644
--- a/test/ti-agent/redefinition_helper.cc
+++ b/test/ti-agent/redefinition_helper.cc
@@ -392,6 +392,7 @@ static void throwRetransformationError(jvmtiEnv* jvmti,
static void DoClassRetransformation(jvmtiEnv* jvmti_env, JNIEnv* env, jobjectArray targets) {
std::vector<jclass> classes;
jint len = env->GetArrayLength(targets);
+ classes.reserve(len);
for (jint i = 0; i < len; i++) {
classes.push_back(static_cast<jclass>(env->GetObjectArrayElement(targets, i)));
}
diff --git a/test/ti-agent/suspension_helper.cc b/test/ti-agent/suspension_helper.cc
index b685cb2a55..2b1ab67a6a 100644
--- a/test/ti-agent/suspension_helper.cc
+++ b/test/ti-agent/suspension_helper.cc
@@ -37,6 +37,7 @@ extern "C" JNIEXPORT jboolean JNICALL Java_art_Suspension_isSuspended(
static std::vector<jthread> CopyToVector(JNIEnv* env, jobjectArray thrs) {
jsize len = env->GetArrayLength(thrs);
std::vector<jthread> ret;
+ ret.reserve(len);
for (jsize i = 0; i < len; i++) {
ret.push_back(reinterpret_cast<jthread>(env->GetObjectArrayElement(thrs, i)));
}
diff --git a/tools/dexanalyze/dexanalyze_experiments.cc b/tools/dexanalyze/dexanalyze_experiments.cc
index b124f433b3..384ab374cd 100644
--- a/tools/dexanalyze/dexanalyze_experiments.cc
+++ b/tools/dexanalyze/dexanalyze_experiments.cc
@@ -459,6 +459,7 @@ void CountDexIndices::ProcessDexFile(const DexFile& dex_file) {
}
// Count uses of top 16n.
std::vector<size_t> uses;
+ uses.reserve(types_accessed.size());
for (auto&& p : types_accessed) {
uses.push_back(p.second);
}